pip - Ansible: install multiple Python packages on a single session -
one of playbooks contains task installs basic python packages:
--- - name: "install python packages: {{ python_packages_to_install }}" sudo: true pip: name={{ item }} with_items: python_packages_to_install
with 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 , installs 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 each line executed using consecutive ssh command, instead of installing packages in single call.
is there way install multiple python packages on ansible pip
command?
expanding on ben's answer, can continue preserve package list yaml list have it, , projection single value when pass pip module like:
pip: name="{{ python_packages_to_install | join(' ') }}"
keeps playbook little more maintainable...
Comments
Post a Comment