From ed6fbb1d84b92afd7bf205554abea03628c02fa7 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 18 Jul 2016 16:25:39 +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: I9a372286efe2105568f9ef2d29be62d0f8070303 --- tasks/sahara_install.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tasks/sahara_install.yml b/tasks/sahara_install.yml index 232e0fb..1466f63 100644 --- a/tasks/sahara_install.yml +++ b/tasks/sahara_install.yml @@ -64,14 +64,13 @@ - name: Install required pip packages pip: - name: "{{ item }}" + name: "{{ sahara_required_pip_packages | join(' ') }}" state: present extra_args: "{{ pip_install_options_fact }}" register: install_packages until: install_packages|success retries: 5 delay: 2 - with_items: "{{ sahara_required_pip_packages }}" tags: - sahara-install - sahara-pip-packages @@ -160,7 +159,7 @@ - name: Install pip packages (venv) pip: - name: "{{ item }}" + name: "{{ sahara_pip_packages | join(' ') }}" state: present virtualenv: "{{ sahara_bin | dirname }}" virtualenv_site_packages: "no" @@ -169,7 +168,6 @@ until: install_packages|success retries: 5 delay: 2 - with_items: "{{ sahara_pip_packages }}" when: - sahara_get_venv | failed or sahara_developer_mode | bool notify: