Install and configure django+nginx+uwsgi+celery stack.
- Postgres client must be set up on the target before applying this role.
- Postgresql server must be up and functional before applying this role, user and database must exist.
- This role does not set up HTTPS, so there must be existing reverse-proxy (another nginx, hardware gateway, etc) in your infrastructure for SSL-terminating purposes.
django_uwsgi_nginx__code_git_repo, default: https://github.com/example-django-app.git. Url of git repository that contains your project.
django_uwsgi_nginx__code_version, default: master. Branch or tag to checkout before installation.
django_uwsgi_nginx__project_name, default: django_app. Name of the project.
django_uwsgi_nginx__deploy_root, default: /opt. Root directory on target host where your app will be deployed.
django_uwsgi_nginx__static_root, default: /var/www/html. Static root on target host.
django_uwsgi_nginx__static_url, default: static. Static url.
django_uwsgi_nginx__media_url, default: media. Media url.
django_uwsgi_nginx__precompiled_subdir, default: precompiled. Subdir for precompiled files generated by cron jobs/celery/etc
django_uwsgi_nginx__monitoring_server, default: 127.0.0.1. Nginx monitoring will be bound to this ip (stub_status)
django_uwsgi_nginx__settings_file, default: "settings.py". Name of main settings file. You can have several settings files - settings_stage.py, settings_prod.py for different environments.
django_uwsgi_nginx__project_domains, default: ["example.com", "www.example.com"]. Domains of your project.
django_uwsgi_nginx__database_server, default: 127.0.0.1. Postgres address.
django_uwsgi_nginx__http_listen, default: 80. Nginx host-port.
django_uwsgi_nginx__database_port, default: 5432. Postgres port.
django_uwsgi_nginx__database_login, default: login. Postgres user.
django_uwsgi_nginx__database_password, default: password. Postgres password.
django_uwsgi_nginx__database_name, default: django. Postgres DB.
django_uwsgi_nginx__database_backup, default: true. If true, database will be backuped before applying any migrations.
django_uwsgi_nginx__database_backup_dir, default: "/srv/backups". If database backup is enabled, it will be stored at this dir on the target host.
django_uwsgi_nginx__celery_user, defalut: celery. System user for celery systemd daemon
django_uwsgi_nginx__celery_group, defalut: celery. System group for celery systemd daemon
django_uwsgi_nginx__upload_media_from, default: None. If set, media files will be uploaded from local machine to the target host. Must be single gzip archive.
None
- name: Install django app
hosts: www
become: true
vars:
django_uwsgi_nginx__upload_media_from: dumps/media.tar.gz
django_uwsgi_nginx__database_backup: false
django_uwsgi_nginx__code_git_repo: "https://git.ru/myproject/myproject-django-app.git"
django_uwsgi_nginx__code_version: stage
django_uwsgi_nginx__project_name: "myproject"
django_uwsgi_nginx__deploy_root: "/opt"
django_uwsgi_nginx__static_root: "/var/www/html"
django_uwsgi_nginx__static_url: "assets"
django_uwsgi_nginx__media_url: "media"
django_uwsgi_nginx__http_listen: "192.168.186.1:80"
django_uwsgi_nginx__monitoring_server: "192.168.186.1"
django_uwsgi_nginx__settings_file: "settings_stage.py"
django_uwsgi_nginx__database_server: 192.168.186.13
django_uwsgi_nginx__database_login: postgres
django_uwsgi_nginx__database_password: secret
django_uwsgi_nginx__database_name: myproject
django_uwsgi_nginx__project_domains:
- stage.myproject.ru
roles:
- django_uwsgi_nginx
tags:
- app
WTFPL
Kirill Shatalaev ksh@solpek.ru