One of my playbooks contains a task that installs basic Python packages:
---
-
name: "Install Python packages: {{ python_packages_to_install }}"
sudo: true
pip: name={{ item }}
with_items: python_packages_to_install
With the following list of packages:
-
include: python_basics.yaml
vars:
python_packages_to_install:
- virtualenv
- pss
- requests
- comment-builder
- boto
- ansible
- uwsgitop
- gitpull
- ipython
The task works correctly and installs the packages:
TASK: [common | Install Python packages: ['virtualenv', 'pss', 'requests', 'comment-builder', 'boto', 'ansible', 'uwsgitop', 'gitpull', 'ipython']] ***
ok: [push-prod-01] => (item=virtualenv)
ok: [push-prod-01] => (item=pss)
ok: [push-prod-01] => (item=requests)
ok: [push-prod-01] => (item=comment-builder)
ok: [push-prod-01] => (item=boto)
ok: [push-prod-01] => (item=ansible)
ok: [push-prod-01] => (item=uwsgitop)
ok: [push-prod-01] => (item=gitpull)
changed: [push-prod-01] => (item=ipython)
The problem is that each line is executed using a consecutive SSH command, instead of installing all the packages in a single call.
Is there a way to install multiple Python packages on an Ansible pip
command?