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: Ib2e9ee2c1f668366905f3c4191bc3a27e84b73ae
This commit is contained in:
Jesse Pretorius 2016-07-18 16:14:47 +01:00
parent 1240dd0cf0
commit ec9d44a53c
3 changed files with 5 additions and 13 deletions

View File

@ -51,14 +51,13 @@
- name: Install requires pip packages - name: Install requires pip packages
pip: pip:
name: "{{ item }}" name: "{{ neutron_requires_pip_packages | join(' ') }}"
state: latest state: latest
extra_args: "{{ pip_install_options_fact }}" extra_args: "{{ pip_install_options_fact }}"
register: install_packages register: install_packages
until: install_packages|success until: install_packages|success
retries: 5 retries: 5
delay: 2 delay: 2
with_items: "{{ neutron_requires_pip_packages }}"
- name: Get local venv checksum - name: Get local venv checksum
stat: stat:
@ -124,7 +123,7 @@
- name: Install pip packages - name: Install pip packages
pip: pip:
name: "{{ item }}" name: "{{ neutron_pip_packages | join(' ') }}"
state: latest state: latest
virtualenv: "{{ neutron_bin | dirname }}" virtualenv: "{{ neutron_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
@ -133,7 +132,6 @@
until: install_packages|success until: install_packages|success
retries: 5 retries: 5
delay: 2 delay: 2
with_items: "{{ neutron_pip_packages }}"
when: when:
- neutron_get_venv | failed or neutron_developer_mode | bool - neutron_get_venv | failed or neutron_developer_mode | bool
notify: Restart neutron services notify: Restart neutron services

View File

@ -14,13 +14,11 @@
- name: Install nuage neutron pip packages - name: Install nuage neutron pip packages
pip: pip:
name: "{{ item }}" name: "{{ neutron_proprietary_nuage_pip_packages | join(' ') }}"
state: latest state: latest
virtualenv: "{{ neutron_bin | dirname }}" virtualenv: "{{ neutron_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
retries: 5 retries: 5
delay: 2 delay: 2
with_items:
- "{{ neutron_proprietary_nuage_pip_packages }}"
when: when:
- neutron_services['neutron-server']['group'] in group_names - neutron_services['neutron-server']['group'] in group_names

View File

@ -30,7 +30,7 @@
- name: Install plumgrid pip packages - name: Install plumgrid pip packages
pip: pip:
name: "{{ item }}" name: "{{ neutron_optional_plumgrid_pip_packages | join(' ') }}"
state: latest state: latest
virtualenv: "{{ neutron_bin | dirname }}" virtualenv: "{{ neutron_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
@ -40,14 +40,12 @@
ignore_errors: True ignore_errors: True
retries: 5 retries: 5
delay: 2 delay: 2
with_items:
- "{{ neutron_optional_plumgrid_pip_packages }}"
when: when:
- neutron_services['neutron-server']['group'] in group_names - neutron_services['neutron-server']['group'] in group_names
- name: Install plumgrid pip packages fall back - name: Install plumgrid pip packages fall back
pip: pip:
name: "{{ item }}" name: "{{ neutron_optional_plumgrid_pip_packages | join(' ') }}"
state: latest state: latest
virtualenv: "{{ neutron_bin | dirname }}" virtualenv: "{{ neutron_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
@ -56,8 +54,6 @@
until: install_packages_fall_back|success until: install_packages_fall_back|success
retries: 5 retries: 5
delay: 2 delay: 2
with_items:
- "{{ neutron_optional_plumgrid_pip_packages }}"
when: when:
- install_packages | failed - install_packages | failed
- neutron_services['neutron-server']['group'] in group_names - neutron_services['neutron-server']['group'] in group_names