Skip to content

Commit

Permalink
Optimise pip install tasks
Browse files Browse the repository at this point in the history
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: Iaca857cbc31a915b8fdecfe4a06f5afb5abb46bf
  • Loading branch information
Jesse Pretorius committed Jul 18, 2016
1 parent e241c37 commit 9b4c1cc
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tasks/horizon_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@

- name: Install requires pip packages
pip:
name: "{{ item }}"
name: "{{ horizon_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: "{{ horizon_requires_pip_packages }}"

- name: Get local venv checksum
stat:
Expand Down Expand Up @@ -125,7 +124,7 @@

- name: Install pip packages
pip:
name: "{{ item }}"
name: "{{ horizon_pip_packages | join(' ') }}"
state: latest
virtualenv: "{{ horizon_bin | dirname }}"
virtualenv_site_packages: "no"
Expand All @@ -134,7 +133,6 @@
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ horizon_pip_packages }}"
when:
- horizon_get_venv | failed or horizon_developer_mode | bool
notify: Restart apache2
Expand Down

0 comments on commit 9b4c1cc

Please sign in to comment.