Pip module reinstalls packages every time

A task I have uses the pip module in conjunction with ‘with_items’ to install different ansible packages, like so:

  • name: install ansible versions
    pip:
    name: ansible
    version: “{{ item }}”
    extra_args: “–install-option="–prefix=/opt/ansible/ansible-{{ item }}"”
    state: present
    with_items:
  • 2.2.1.0
  • 2.3.0.0
  • 2.3.1.0
  • 2.4.2.0
  • 2.4.4.0

Every time we run the playbook Ansible reinstalls the packages even though they are definitely there on the host. Any ideas why?

Thanks,
Guy