Get some new READMEs in place. Add Ansible placeholder.

This commit is contained in:
Luke Murphy 2018-11-17 21:39:21 +01:00
parent 416dfc2cef
commit d9d00aab93
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
15 changed files with 183 additions and 68 deletions

View File

@ -1,77 +1,23 @@
# XPUB Library
Library running on Flask and SQLight (maybe to be replaced with a python shelve)
# Varia's XPPL
requirements.txt
$ pip3 install -r requirements.txt
The [XPUB] library living at [Varia].
install rqlite
install pyrqlite
install sqlalchemy-rqlite
> https://books.vvvvvvaria.org/
initialize rqlite database
$ ./rqlited ~.node
[XPUB]: http://xpub.nl/#0/-128/128
[Varia]: https://varia.zone/
initialise database
$ bash init_db.sh
# Hack It
run script
python3 run.py
Install [Pipenv] and then run the development server with:
```bash
$ pipenv install --dev --three
$ pipenv run dev
```
## API
[Pipenv]: https://pipenv.readthedocs.io/en/latest/install/#pragmatic-installation-of-pipenv
has currently 2 entrypoints:
/api/books
GETs all the books in the database
/api/book/id
GETs a specific book by its id
## Installation
Further installnotes (bugs)
* create the covers folder inside the uploadsfolder
* don't forget to chmod the uploads and coverfolder ;-)
* For Macusers -> brew install imagemagick@6 in order to install wand
For those on mac and using homebrew, it seems like Wand doesn't support imagemagick 7 yet as mentioned in other answers.
There's a new brew formula for Imagemagick 6 which can be used to install the older version in the meanwhile:
brew install imagemagick@6
Create a symlink to this newly installed dylib file as mentioned in other answer to get things working.
ln -s /usr/local/Cellar/imagemagick@6/<your specific 6 version>/lib/libMagickWand-6.Q16.dylib /usr/local/lib/libMagickWand.dylib
## install rqlite
### Linux
To download and start rqlite on Linux, execute the following in a shell.
curl -L https://github.com/rqlite/rqlite/releases/download/v4.3.0/rqlite-v4.3.0-linux-amd64.tar.gz -o rqlite-v4.3.0-linux-amd64.tar.gz
tar xvfz rqlite-v4.3.0-linux-amd64.tar.gz
cd rqlite-v4.3.0-linux-amd64
./rqlited ~/node.1
### OSX
To download and start rqlite on OSX, execute the following in a shell.
curl -L https://github.com/rqlite/rqlite/releases/download/v4.3.0/rqlite-v4.3.0-darwin-amd64.tar.gz -o rqlite-v4.3.0-darwin-amd64.tar.gz
tar xvfz rqlite-v4.3.0-darwin-amd64.tar.gz
cd rqlite-v4.3.0-darwin-amd64
./rqlited ~/node.1
## install pyrqlite
git clone https://github.com/rqlite/pyrqlite.git
pip install ./pyrqlite
## install sqlalchemy-rqlite
git clone https://github.com/rqlite/sqlalchemy-rqlite.git
cd sqlalchemy-rqlite
sudo python3 ./setup.py install
# Deploy It
See [ansible/README.md](ansible/README.md) for this.

24
ansible/README.md Normal file
View File

@ -0,0 +1,24 @@
# XPPL Ansible Automation
An automated deployment for the XPPL.
## Run It
You'll need to have SSH and Sudo access to [varia.zone] first.
```bash
$ sudo apt install -y ansible
$ ansible-playbook --ask-become-pass plays/main.yml
```
[varia.zone]: https://varia.zone/
## What Does It Do?
* Clone the Python application into `/var/xppl/`.
* Get the RQLite database running managed under [Supervisord].
* Run the [Gunicorn] WSGI server to server the Python application.
* Proxy the WSGI server with an NGINX configuration.
[Gunicorn]: https://gunicorn.org/
[Supervisord]: http://supervisord.org/introduction.html#features

12
ansible/ansible.cfg Normal file
View File

@ -0,0 +1,12 @@
[defaults]
forks=10
internal_poll_interval=0.004
inventory=inventory
roles_path=roles
[privilege_escalation]
become=False
become_method=sudo
[ssh_connection]
pipelining=True

5
ansible/inventory Normal file
View File

@ -0,0 +1,5 @@
[dev]
localhost ansible_connection=local
[prod]
varia.zone ansible_ssh_port=12345

5
ansible/plays/main.yml Normal file
View File

@ -0,0 +1,5 @@
---
- hosts: prod
roles:
- role: xppl

View File

@ -0,0 +1,13 @@
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
# truthy: disable

View File

@ -0,0 +1,48 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should
be mentioned here. For instance, if the role uses the EC2 module, it may be a
good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including
any variables that are in defaults/main.yml, vars/main.yml, and any variables
that can/should be set via parameters to the role. Any variables that are read
from other roles and/or the global scope (ie. hostvars, group vars, etc.) should
be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in
regards to parameters that may need to be set for other roles, or variables that
are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables
passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: xppl, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a
website (HTML is not allowed).

View File

@ -0,0 +1 @@
---

View File

@ -0,0 +1 @@
---

View File

@ -0,0 +1,10 @@
---
galaxy_info:
author: decentral1se
description: Ansible automation for the XPPL.
license: GPLv3
min_ansible_version: 2.7.2
galaxy_tags: []
dependencies: []

View File

@ -0,0 +1,9 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean

View File

@ -0,0 +1,26 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance
image: debian:stretch
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8

View File

@ -0,0 +1,6 @@
---
- name: Converge
hosts: all
roles:
- role: xppl

View File

@ -0,0 +1,8 @@
---
# create /var/xppl
# clone the latest source there
# get supervisord installed
# get the rqlite database setup with supervisor
# get the nginx certificate in place
# run the gunicorn server

View File

@ -0,0 +1 @@
---