ansible role to install a django app
Go to file
jens 194f503e8f
continuous-integration/drone/push Build is passing Details
Update 'tasks/main.yml'
2022-05-30 08:16:05 +00:00
defaults Update 'defaults/main.yml' 2021-09-14 08:13:35 +00:00
handlers Update 'handlers/main.yml' 2021-09-14 10:14:53 +00:00
meta fix linting 2021-08-31 12:06:24 +02:00
tasks Update 'tasks/main.yml' 2022-05-30 08:16:05 +00:00
templates made more generic 2021-08-30 14:59:41 +02:00
tests made more generic 2021-08-30 14:59:41 +02:00
vars made more generic 2021-08-30 14:59:41 +02:00
.drone.yml Update '.drone.yml' 2021-09-14 07:55:04 +00:00 Update '' 2021-09-14 13:01:51 +00:00 made more generic 2021-08-30 14:59:41 +02:00

Ansible role Djangoapp

Build Status

This role installs a django app given the download url for it's tar.gz


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 which will be templated by jinja with the vars defined and used as settings file for this django app.

Role Variables

  • django_app_gitrepo: git repo to check out (required)
  • django_app_gitversion: git thing to check out defautls to "main"
  • 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



Example Playbook

- name: "Install im pantry app"
  hosts: im
      - ansible-role-djangoapp
      - django_domain: ""
      - django_http_listen: "{{inventory_hostname}}"
      - django_admin_password: "test"
      - django_app_gitrepo: ""
      - django_app_gitversion: "main"
- name: "install posgres servers"
  hosts: pa
    - ansible-role-postgresql
    - postgresql_python_library: python3-psycopg2
    - postgresql_databases:
      - name: "{{inventory_hostname}}"
        owner: "{{inventory_hostname}}"
    - postgresql_users:
      - name: "{{inventory_hostname}}"

- name: "Install im pantry app"
  hosts: im
      - ansible-role-djangoapp
      - django_appname: "im"
      - django_domain: ""
      - django_admin_email: ""
      - django_http_listen: "{{inventory_hostname}}"
      - django_http_listen: ""
      - django_http_port: 8000
      # needs to be a tar.gz for now
      # needs to have a file in the django_appname folder
      - django_app_gitrepo: ""
      - django_app_gitversion: "v2.0"
      - django_admin_password: !vault |



Author Information

Jens (