私はansible
私の展開に使用していますdjango App
使用して
- name: Upgrade the virtualenv.
pip: requirements={{project_root}}/www/requirements.txt virtualenv={{project_root}}/www/virtualenv
しかし、最後の実行以降にrequirements.txtが変更された場合にのみ実行したい
私はansible
私の展開に使用していますdjango App
使用して
- name: Upgrade the virtualenv.
pip: requirements={{project_root}}/www/requirements.txt virtualenv={{project_root}}/www/virtualenv
しかし、最後の実行以降にrequirements.txtが変更された場合にのみ実行したい
次の 2 つのオプションがあります。
requirements.txt を Ansible の制御下に置き、'copy' または 'template' モジュールを使用してから、'notify:' ステートメントで 'pip' モジュールを呼び出します。
2 番目の方法はより複雑です。
私はgitリポジトリに対してこの非常に短い回避策を使用しています。
- name: get requirements changes since last pull
shell: "cd {{ project_root }}; git log --name-status --oneline origin/master
{{ git_result.before }}..{{ git_result.after }} | grep requirements.txt"
register: pip_check
failed_when: false
- name: update pip requirements
pip: requirements={{ project_root }}/requirements.txt
virtualenv=~/.virtualenvs/www/
when: pip_check.stdout_lines
普遍的ではなく、クロスプラットフォームのレシピでもありませんが、多くの状況でうまく機能します.