I am using ansible
to deploy my django App
using
- name: Upgrade the virtualenv.
pip: requirements={{project_root}}/www/requirements.txt virtualenv={{project_root}}/www/virtualenv
But i only want to run that if requirements.txt changed since last run
Here are two options:
put your requirements.txt under Ansible control and use 'copy' or 'template' module, then invoke 'pip' module with 'notify:' statement
second way is more complex:
I use this pretty short workaround for git repository.
It's not universal and not cross-platform recipe, but works well for many situations.
We need to determine if any of the requirement files have changed. The steps are as follows:
Here's my playbook, {{virtualenv.requirements}} is a list of requirement files, eg:
['/work/project/requirements.txt', '/work/project/requirements-prod.txt']
: