Cpanm Ansible with List

427 views Asked by At

Recently been trying to get get Ansible working with Cpanm. I have read

https://docs.ansible.com/ansible/2.5/modules/cpanm_module.html

and been able to install one perl module using the code below:

# install Dancer perl package
- cpanm:
name: Dancer

However everytime I try to use a list of items like so:

- name: Install OS utilities
dnf: name="{{ item }}" state=present
with_items: "{{ utils.deb }}"

- name: Install pip modules
pip: name="{{ item }}" state=present
with_items: "{{ utils.pip }}"

- name: Install the perl modules
cpanm:
name: "{{ item }}"
with_items: "{{ utils.cpanm }}" 

it will throw:

docker: failed: [default] (item=Array::Utils) => {"changed": false, "item": "Array::Utils", "msg": "one of the following is required: name, from_path"}

for each of the modules that I want to install

Any ideas on what I am doing wrong so that I don't have to install them via shell or doing the first bit of code for each module?

Thank you

1

There are 1 answers

0
sebthebert On

Probably an indentation issue, you should have:

- name: Install Perl modules
  cpanm:
    path: "{{ item }}"
  with_items:
    - module1
    - module2