From d9d00aab9307c2a64d2ab703b45336a55b567e56 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 17 Nov 2018 21:39:21 +0100 Subject: [PATCH] Get some new READMEs in place. Add Ansible placeholder. --- README.md | 82 ++++--------------- ansible/README.md | 24 ++++++ ansible/ansible.cfg | 12 +++ ansible/inventory | 5 ++ ansible/plays/main.yml | 5 ++ ansible/roles/xppl/.yamllint | 13 +++ ansible/roles/xppl/README.md | 48 +++++++++++ ansible/roles/xppl/defaults/main.yml | 1 + ansible/roles/xppl/handlers/main.yml | 1 + ansible/roles/xppl/meta/main.yml | 10 +++ .../roles/xppl/molecule/default/Dockerfile.j2 | 9 ++ .../roles/xppl/molecule/default/molecule.yml | 26 ++++++ .../roles/xppl/molecule/default/playbook.yml | 6 ++ ansible/roles/xppl/tasks/main.yml | 8 ++ ansible/roles/xppl/vars/main.yml | 1 + 15 files changed, 183 insertions(+), 68 deletions(-) create mode 100644 ansible/README.md create mode 100644 ansible/ansible.cfg create mode 100644 ansible/inventory create mode 100644 ansible/plays/main.yml create mode 100644 ansible/roles/xppl/.yamllint create mode 100644 ansible/roles/xppl/README.md create mode 100644 ansible/roles/xppl/defaults/main.yml create mode 100644 ansible/roles/xppl/handlers/main.yml create mode 100644 ansible/roles/xppl/meta/main.yml create mode 100644 ansible/roles/xppl/molecule/default/Dockerfile.j2 create mode 100644 ansible/roles/xppl/molecule/default/molecule.yml create mode 100644 ansible/roles/xppl/molecule/default/playbook.yml create mode 100644 ansible/roles/xppl/tasks/main.yml create mode 100644 ansible/roles/xppl/vars/main.yml diff --git a/README.md b/README.md index a677a9c..e11e3b4 100644 --- a/README.md +++ b/README.md @@ -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//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. diff --git a/ansible/README.md b/ansible/README.md new file mode 100644 index 0000000..9791245 --- /dev/null +++ b/ansible/README.md @@ -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 diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..26760bb --- /dev/null +++ b/ansible/ansible.cfg @@ -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 diff --git a/ansible/inventory b/ansible/inventory new file mode 100644 index 0000000..8639d1f --- /dev/null +++ b/ansible/inventory @@ -0,0 +1,5 @@ +[dev] +localhost ansible_connection=local + +[prod] +varia.zone ansible_ssh_port=12345 diff --git a/ansible/plays/main.yml b/ansible/plays/main.yml new file mode 100644 index 0000000..12eb2ef --- /dev/null +++ b/ansible/plays/main.yml @@ -0,0 +1,5 @@ +--- + +- hosts: prod + roles: + - role: xppl diff --git a/ansible/roles/xppl/.yamllint b/ansible/roles/xppl/.yamllint new file mode 100644 index 0000000..3a2255e --- /dev/null +++ b/ansible/roles/xppl/.yamllint @@ -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 diff --git a/ansible/roles/xppl/README.md b/ansible/roles/xppl/README.md new file mode 100644 index 0000000..442bf67 --- /dev/null +++ b/ansible/roles/xppl/README.md @@ -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). diff --git a/ansible/roles/xppl/defaults/main.yml b/ansible/roles/xppl/defaults/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/ansible/roles/xppl/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/ansible/roles/xppl/handlers/main.yml b/ansible/roles/xppl/handlers/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/ansible/roles/xppl/handlers/main.yml @@ -0,0 +1 @@ +--- diff --git a/ansible/roles/xppl/meta/main.yml b/ansible/roles/xppl/meta/main.yml new file mode 100644 index 0000000..aab6030 --- /dev/null +++ b/ansible/roles/xppl/meta/main.yml @@ -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: [] diff --git a/ansible/roles/xppl/molecule/default/Dockerfile.j2 b/ansible/roles/xppl/molecule/default/Dockerfile.j2 new file mode 100644 index 0000000..25e1bef --- /dev/null +++ b/ansible/roles/xppl/molecule/default/Dockerfile.j2 @@ -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 diff --git a/ansible/roles/xppl/molecule/default/molecule.yml b/ansible/roles/xppl/molecule/default/molecule.yml new file mode 100644 index 0000000..107602d --- /dev/null +++ b/ansible/roles/xppl/molecule/default/molecule.yml @@ -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 diff --git a/ansible/roles/xppl/molecule/default/playbook.yml b/ansible/roles/xppl/molecule/default/playbook.yml new file mode 100644 index 0000000..4d193a4 --- /dev/null +++ b/ansible/roles/xppl/molecule/default/playbook.yml @@ -0,0 +1,6 @@ +--- + +- name: Converge + hosts: all + roles: + - role: xppl diff --git a/ansible/roles/xppl/tasks/main.yml b/ansible/roles/xppl/tasks/main.yml new file mode 100644 index 0000000..4b4a347 --- /dev/null +++ b/ansible/roles/xppl/tasks/main.yml @@ -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 diff --git a/ansible/roles/xppl/vars/main.yml b/ansible/roles/xppl/vars/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/ansible/roles/xppl/vars/main.yml @@ -0,0 +1 @@ +---