From ec9d44a53c86fdbe73392c8f0f7f9dc97dcdaa3d Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 18 Jul 2016 16:14:47 +0100 Subject: [PATCH] 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 --- tasks/neutron_install.yml | 6 ++---- tasks/nuage_neutron_config.yml | 4 +--- tasks/plumgrid_config.yml | 8 ++------ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/tasks/neutron_install.yml b/tasks/neutron_install.yml index e6cbed20..6b430a1f 100644 --- a/tasks/neutron_install.yml +++ b/tasks/neutron_install.yml @@ -51,14 +51,13 @@ - name: Install requires pip packages pip: - name: "{{ item }}" + name: "{{ neutron_requires_pip_packages | join(' ') }}" state: latest extra_args: "{{ pip_install_options_fact }}" register: install_packages until: install_packages|success retries: 5 delay: 2 - with_items: "{{ neutron_requires_pip_packages }}" - name: Get local venv checksum stat: @@ -124,7 +123,7 @@ - name: Install pip packages pip: - name: "{{ item }}" + name: "{{ neutron_pip_packages | join(' ') }}" state: latest virtualenv: "{{ neutron_bin | dirname }}" virtualenv_site_packages: "no" @@ -133,7 +132,6 @@ until: install_packages|success retries: 5 delay: 2 - with_items: "{{ neutron_pip_packages }}" when: - neutron_get_venv | failed or neutron_developer_mode | bool notify: Restart neutron services diff --git a/tasks/nuage_neutron_config.yml b/tasks/nuage_neutron_config.yml index 994a62be..0a072cee 100644 --- a/tasks/nuage_neutron_config.yml +++ b/tasks/nuage_neutron_config.yml @@ -14,13 +14,11 @@ - name: Install nuage neutron pip packages pip: - name: "{{ item }}" + name: "{{ neutron_proprietary_nuage_pip_packages | join(' ') }}" state: latest virtualenv: "{{ neutron_bin | dirname }}" virtualenv_site_packages: "no" retries: 5 delay: 2 - with_items: - - "{{ neutron_proprietary_nuage_pip_packages }}" when: - neutron_services['neutron-server']['group'] in group_names diff --git a/tasks/plumgrid_config.yml b/tasks/plumgrid_config.yml index d8d9aea0..6c03ea60 100644 --- a/tasks/plumgrid_config.yml +++ b/tasks/plumgrid_config.yml @@ -30,7 +30,7 @@ - name: Install plumgrid pip packages pip: - name: "{{ item }}" + name: "{{ neutron_optional_plumgrid_pip_packages | join(' ') }}" state: latest virtualenv: "{{ neutron_bin | dirname }}" virtualenv_site_packages: "no" @@ -40,14 +40,12 @@ ignore_errors: True retries: 5 delay: 2 - with_items: - - "{{ neutron_optional_plumgrid_pip_packages }}" when: - neutron_services['neutron-server']['group'] in group_names - name: Install plumgrid pip packages fall back pip: - name: "{{ item }}" + name: "{{ neutron_optional_plumgrid_pip_packages | join(' ') }}" state: latest virtualenv: "{{ neutron_bin | dirname }}" virtualenv_site_packages: "no" @@ -56,8 +54,6 @@ until: install_packages_fall_back|success retries: 5 delay: 2 - with_items: - - "{{ neutron_optional_plumgrid_pip_packages }}" when: - install_packages | failed - neutron_services['neutron-server']['group'] in group_names