Optimise pip install tasks

Unlike the Ansible apt module, the Ansible pip module does not
recognise a with_items list and process all the items at once.

To optimise the pip install tasks, this patch replaces the use
of with_items with a join filter so that the pip install task
does an install with all the packages in a list, ensuring that
the execution is one action instead of many.

Change-Id: Idfb5059b60b2edb61113fecc9ad33f90a2ab9e65
This commit is contained in:
Jesse Pretorius 2016-07-18 16:32:31 +01:00
parent 323aa88346
commit 6dedbe271c
1 changed files with 2 additions and 4 deletions

View File

@ -60,14 +60,13 @@
- name: Install requires pip packages
pip:
name: "{{ item }}"
name: "{{ zaqar_requires_pip_packages | join(' ') }}"
state: latest
extra_args: "{{ pip_install_options|default('') }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ zaqar_requires_pip_packages }}"
tags:
- zaqar-install
- zaqar-pip-packages
@ -170,7 +169,7 @@
- name: Install pip packages (venv)
pip:
name: "{{ item }}"
name: "{{ zaqar_pip_packages | join(' ') }}"
state: latest
virtualenv: "{{ zaqar_bin | dirname }}"
virtualenv_site_packages: "no"
@ -179,7 +178,6 @@
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ zaqar_pip_packages }}"
when:
- zaqar_get_venv | failed or zaqar_developer_mode | bool or zaqar_local_mode | bool
# notify: