Hi there,

I'm trying to create an ansible module to install packages using a custom 
package management system. I want it to function like the core yum module 
says it does when used in a loop, i.e. "Instead of calling the module with 
a single package each time through the loop, ansible calls the module once 
with all of the package names from the loop"

How would I replicate this in my own module?

I couldn't see anything special in the source for the yum module that would 
enable this behaviour.

I tried just specifying the input as type list, simplified below:

module = AnsibleModule(
    argument_spec = dict(
        name=dict(type="list", required=True),
    ),
    supports_check_mode = True
)
cmd = [ 'pkg_agent', '-X', ','.join(module.params'name']) ]
rc, out, err = module.run_command(cmd)

But when I used my module in a playbook, it didn't work:
  tasks:
    - name: "Install packages"
      pkg_install:
        name: "{{ item }}"
      become: True
      with_items:
        - 'common-tests'
        - 'ops-libs'

Both the debug output and the resulting behaviour was it running the 
install on each package individually, and not bundling them together.

The expected result was that it would run `pkg_agent -X 
common-tests,ops-libs` but what in fact happened is it ran `pkg_agent -X 
common-tests` and then `pkg_agent -X ops-libs`

This was using Ansible 2.2 on Ubuntu

Any help in where I've gone wrong with this would be much appreciated.

- Peter

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e8979679-511c-42e7-8b90-b10f6c153f14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to