ansible-role-djangoapp/README.md

102 lines
3.7 KiB
Markdown
Raw Permalink Normal View History

2021-08-31 10:07:35 +00:00
Ansible role Djangoapp
2020-09-10 22:31:09 +00:00
=========
2021-08-31 10:07:35 +00:00
[![Build Status](https://drone.caret.be/api/badges/jens/ansible-role-djangoapp/status.svg)](https://drone.caret.be/jens/ansible-role-djangoapp)
This role installs a django app given the download url for it's tar.gz
2020-09-10 22:31:09 +00:00
Requirements
------------
2021-09-14 13:01:51 +00:00
This role requires a database server to to be present where the django app can connect to.
The git checkout of the app should have a file called `settings_template.py.j2` which will be templated by jinja with the vars defined and used as settings file for this django app.
2020-09-10 22:31:09 +00:00
Role Variables
--------------
2021-09-14 07:21:27 +00:00
- `django_app_gitrepo`: git repo to check out (required)
- `django_app_gitversion`: git thing to check out defautls to "main"
2021-08-30 12:59:41 +00:00
- `django_admin_password`: required, password for 'admin' user
- `django_secret_key`: optional Secret Key for Django app, defaults to random 56char string recreated on every run (This will invalidated current open sessions)
- `django_user`: user running the app, defaults to 'django' (this user will be created)
- `django_home`: path to install the djangoapp in, defaults to /home/django (this path will be created)
- `django_domain`: the domain this app will run on (Needed for django's ALLOWED_HOSTS), default localhost
- `django_db_name`: database name, defaults to 'django'
- `django_db_user`: database user, defaults to 'django'
- `django_db_password`: database password, defaults to '', (ignored for unix socket connection)
- `django_db_host`: database server, defaults to '/run/postgresql/' for local unix socket connection
- `django_db_port`: database port, defaults to 5432 (ignored for unix socket connection)
- `django_workers`: the number of gunicorn http worker threads (defaults to 4)
- `django_http_listen`: the ip address to bind to, change this to ip address of the host if you use a reverse proxy on a different host, defaults to localhost
- `django_http_port`: the http port to bind to, defaults to 80
2020-09-10 22:31:09 +00:00
Dependencies
------------
2020-09-10 23:08:02 +00:00
None
2020-09-10 22:31:09 +00:00
Example Playbook
----------------
2020-09-10 23:08:02 +00:00
```yaml
- name: "Install im pantry app"
hosts: im
roles:
2021-08-30 12:59:41 +00:00
- ansible-role-djangoapp
2020-09-10 23:08:02 +00:00
vars:
2021-08-30 12:59:41 +00:00
- django_domain: "im.example.com"
- django_http_listen: "{{inventory_hostname}}"
- django_admin_password: "test"
2021-08-31 10:22:23 +00:00
- django_app_gitrepo: "https://gitea.caret.be/jens/im.git"
- django_app_gitversion: "main"
2020-09-10 23:08:02 +00:00
```
2020-09-10 22:31:09 +00:00
2020-09-10 23:38:28 +00:00
```yaml
2021-09-14 07:21:27 +00:00
- name: "install posgres servers"
hosts: pa
roles:
- ansible-role-postgresql
vars:
- postgresql_python_library: python3-psycopg2
- postgresql_databases:
- name: "{{inventory_hostname}}"
owner: "{{inventory_hostname}}"
- postgresql_users:
- name: "{{inventory_hostname}}"
2020-09-10 23:38:28 +00:00
- name: "Install im pantry app"
hosts: im
roles:
2021-08-30 12:59:41 +00:00
- ansible-role-djangoapp
2020-09-10 23:38:28 +00:00
vars:
2021-08-30 12:59:41 +00:00
- django_appname: "im"
- django_domain: "im.example.com"
- django_admin_email: "im@example.com"
- django_http_listen: "{{inventory_hostname}}"
- django_http_listen: "192.168.1.112"
- django_http_port: 8000
# needs to be a tar.gz for now
# needs to have a settings_template.py.j2 file in the django_appname folder
2021-08-31 10:22:23 +00:00
- django_app_gitrepo: "https://gitea.caret.be/jens/im.git"
- django_app_gitversion: "v2.0"
2021-08-30 12:59:41 +00:00
- django_admin_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
33366337663233346138373232353438613362636634393334613935303466343238646361613037
3738623833643738636162303362383665646132616362320a366338313363356634636534653932
36383131333437613236303662346637633536373637343562336465663639353765616130353536
3439653639343234390a636334383262663363353030333837316430383762346463386166626637
6536
2020-09-10 23:38:28 +00:00
```
2020-09-10 22:31:09 +00:00
License
-------
2020-09-10 23:08:02 +00:00
GPL-v3
2020-09-10 22:31:09 +00:00
Author Information
------------------
2020-09-10 23:08:02 +00:00
Jens (gitea.caret.be)