pip install list of packages

Hi

If I'm using pip with name being a list of packages, for instance:

- name: Install stuff
  pip:
    name:
      - pyyaml
      - natsort
      - passlib

Then the module will do "pip install pyyaml natsort passlib", and not:

pip install pyyaml
pip install natsort
pip install passlib

Is this assumption correct?

Hi Dick,

I’m doing this:

  • name: Install Python packages
    pip:
    name: “{{ item.name }}”
    version: “{{ item.version }}”
    executable: pip2
    become: yes
    with_items:
  • { name: ‘alembic’, version: ‘1.1.0’ }
  • { name: ‘aniso8601’, version: ‘7.0.0’ }
  • { name: ‘anyjson’, version: ‘0.3.3’ }
  • { name: ‘articleDateExtractor’, version: ‘0.20’ }

And it pip installs every one of them separately.

It seems that I was wrong.
Ansible runs each of my iterations as a different command because I’m using with_items.

Yes, I noticed that.
So that is the distinction then.
I guess this is similar to the apt/package/etc modules, where you are
encouraged to use a list for 'name' so that the package manager can
install the whole lot in one go.

thx