This role is designed to provide all the needed directories, config files, service units, and service handlers for managing gunicorn services using systemd on Ubuntu. It does not manage the installation of a gunicorn binary, users, groups, or wsgi applications.
Ubuntu 18.04+
Defaults
gunicorn_config_dir: /etc/gunicorn
gunicorn_log_dir: /var/log/gunicorn
gunicorn_systemd_service_dir: /etc/systemd/system
gunicorn_access_logfile: "{{gunicorn_log_dir}}/access.log"
gunicorn_python_path: /usr
gunicorn_tmp_dir: /run/lock
gunicorn_read_timeout: 60
gunicorn_user: gunicorn
gunicorn_bind_port: '127.0.0.1:8000'
gunicorn_start_command: "{{gunicorn_python_path}}/bin/gunicorn"
gunicorn_install_service: true
gunicorn_enable_service: false
gunicorn_environment: {}
Required Vars
gunicorn_app_dir
gunicorn_wsgi_module_name
gunicorn_state - when gunicorn_enable_service=True
Note that environment variables that need to be enclosed by quotes should have them explicitly defined.
In addition, since systemd units are only capable of reading a single EnvironmentFile, if global Environment Variables are for both celery and non-celery service units - you may optionally define a variable "service_global_env" dictionary of those Environment Variables that will be additionally appended to the Celery Systemd Service Unit.
None
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: localhost
vars:
gunicorn_app_dir: /srv/django
gunicorn_wsgi_module_name: django_app.wsgi:application
gunicorn_user: django
gunicorn_environment: { DJANGO_SETTINGS_MODULE: django.settings, HOME: "{{gunicorn_app_dir}}", PATH: django_virtualenv/bin }
roles:
- { role: ansible-role-gunicorn }
BSD 3-Clause