This repository holds an Ansible role
that is installable using ansible-galaxy. This role contains
tasks used to install and set up a Django web app. It exists
primarily to support the Caktus Django project template.
This Ansible role is released under the BSD License. See the LICENSE file for more details.
If you think you've found a bug or are interested in contributing to this project check out tequila-django on Github.
Development sponsored by Caktus Consulting Group, LLC.
Create an ansible.cfg file in your project directory to tell
Ansible where to install your roles (optionally, set the
ANSIBLE_ROLES_PATH environment variable to do the same thing, or
allow the roles to be installed into /etc/ansible/roles)
[defaults] roles_path = deployment/roles/
Create a requirements.yml file in your project's deployment
directory. It is recommended to include tequila-common, which sets up
the project directory structure and users, and also geerlingguy/nodejs
to install nodejs and any front-end packages that your project
requires
--- # file: deployment/requirements.yml - src: geerlingguy.nodejs version: 4.1.2 name: nodejs - src: https://github.com/caktus/tequila-common version: v0.8.0 - src: https://github.com/caktus/tequila-django version: v0.9.3
Run ansible-galaxy with your requirements file
$ ansible-galaxy install -r deployment/requirements.yml
or, alternatively, run it directly against the url
$ ansible-galaxy install git+https://github.com/caktus/tequila-django
The project then should have access to the tequila-django role in
its playbooks.
The following variables are used by the tequila-django role:
project_namerequiredenv_namerequireddomainrequiredadditional_domainsdefault: empty listis_webdefault:false(required: one ofis_weboris_workerset totrue)is_workerdefault:falsepython_versiondefault:"2.7"root_dirdefault:"/var/www/{{ project_name }}"source_dirdefault:"{{ root_dir }}/src"venv_dirdefault:"{{ root_dir }}/env"ssh_dirdefault:"/home/{{ project_name }}/.ssh"requirements_filedefault:"{{ source_dir }}/requirements/{{ env_name }}.txt"requirements_extra_argsdefault:""use_newrelicdefault:falsenew_relic_license_keyrequired if use_newrelic is truecloud_staticfilesdefault:falsegunicorn_versionoptionalgunicorn_num_workersrequiredgunicorn_num_threadsoptional (note: gunicorn sets this at1if--threads=...is not given)project_userdefault:"{{ project_name }}"project_settingsdefault:"{{ project_name }}.settings.deploy"secret_keyrequireddb_namedefault:"{{ project_name }}_{{ env_name }}"db_userdefault:"{{ project_name }}_{{ env_name }}"db_hostdefault:'localhost'db_portdefault:5432db_passwordrequiredcache_hostoptionalbroker_hostoptionalbroker_passwordoptionalcelery_worker_extra_argsdefault:"--loglevel=INFO"static_dirdefault:"{{ root_dir }}/public/static"media_dirdefault:"{{ root_dir }}/public/media"log_dirdefault:"{{ root_dir }}/log"reporequired: dict containing url and branchsource_is_localdefault:falsegithub_deploy_keyrequired if source_is_local is falselocal_project_dirrequired if source_is_localextra_envdefault: empty dict
The extra_env variable is a dict of keys and values that is
desired to be injected into the environment as variables, via the
envfile.j2 template.
Note that if source_is_local is set to false, a Github checkout
key needs to be provided in the environment secrets file, and that key
needs to be added to the repo's settings within Github.
Alternatively, if source_is_local is set to true, the user's local
checkout of the repo is rsynced into the environment, with a few
exclusions (.pyc files, the .git directory, the .env file, and the
node_modules directory).
The cloud_staticfiles variable is to allow for the case where the
Django static files are being collected to an external service, such
as S3. In that case, we don't want to be running collectstatic on
every web instance, since they'll be getting in each other's way.
This variable set to true causes the collectstatic task to be
run only once.
You can turn on SSH pipelining (http://docs.ansible.com/ansible/latest/intro_configuration.html#pipelining) to speed up ansible commands (by minimizing SSH operations). Add the following to your project's ansible.cfg file
[ssh_connection] pipelining = True
Warning: this will cause deployments to break if securetty is used in your server's
/etc/sudoers file.
See geerlingguy/nodejs for the expected Ansible configuration variables for that role.