---
# install all requirements from requirements.txt
#
# use_pip_compile == True:
#   before installing requirements.txt, install pip-tools and recompile
#   requirements inputs configured in requirement_files
#
# tag: update_requirements
#

- name: install pip-tools
  pip:
    state: latest
    virtualenv: "{{ virtualenv_path }}"
    name: "{{ packages }}"
  vars:
    packages:
    - "pip~=18.0"
    - "pip-tools~=3.2.0"
  when: use_pip_compile

- name: recompile requirements input
  command: >
    {{ virtualenv_path }}/bin/pip-compile {{ install_path }}/requirements/{{ item }}.in --upgrade
  with_items: '{{ requirement_files }}'
  when: use_pip_compile and not disabled_by_default

- name: install django app requirements
  pip:
    state: latest
    virtualenv: "{{ virtualenv_path }}"
    extra_args: "--exists-action w"
    requirements: "{{ install_path }}/{{ requirements }}"
  notify:
    - restart service group

---
# install all requirements from requirements.txt
#
# use_pip_compile == True:
#   before installing requirements.txt, install pip-tools and recompile
#   requirements inputs configured in requirement_files
#
# tag: update_requirements
#

- name: install pip-tools
  pip:
    state: latest
    virtualenv: "{{ virtualenv_path }}"
    name: "{{ packages }}"
  vars:
    packages:
    - "pip"
    - "pip-tools"
  when: use_pip_compile

- name: recompile requirements input
  command: >
    {{ virtualenv_path }}/bin/pip-compile {{ install_path }}/requirements/{{ item }}.in --upgrade
  with_items: '{{ requirement_files }}'
  when: use_pip_compile and not disabled_by_default

- name: install django app requirements
  pip:
    state: latest
    virtualenv: "{{ virtualenv_path }}"
    extra_args: "--exists-action w"
    requirements: "{{ install_path }}/{{ requirements }}"
  notify:
    - restart service group

Use latest pip & pip-tools
Use latest pip & pip-tools
