Day 7: Special topics¶
Yesterday you used Ansible’s
file module to create directories, and
template module to create the Django application’s
settings.py file. Today you will create two handlers that will
manage.py collectstatic and
This assignment is going to take you at least 15 minutes, so we will not do anything else today.
Your assignment is to create two handlers: a
collect static handler
migrate handler. The handlers shall do the equivalent of these
export PYTHONPATH=/etc/opt/$DJANGO_PROJECT export DJANGO_SETTINGS_MODULE=settings cd /opt/$DJANGO_PROJECT ./venv/bin/python manage.py collectstatic su $DJANGO_USER -c 'venv/bin/python manage.py migrate'
Use the Ansible
commandmodule for both, and make sure you are using the virtualenv
Check the Ansible documentation on “Understanding privilege escalation: become” and “Setting the remote environment”
Make sure the
gittask and the
settings.pytask notify these handlers in addition to the compile handler
To make them run, do something that will cause the
gittask or the
settings.pytask to modify something; for example, logon to the server and add an empty line to
Tomorrow we will see the solution and we will setup nginx.