Hi Peter, you'll need to add your module name to the `squash_actions` ansible.cfg setting. The default value of that is "apk, apt, dnf, homebrew, pacman, pkgng, yum, zypper", so just append your module to the list.
James Cammarata Ansible Lead/Sr. Principal Software Engineer Ansible by Red Hat twitter: @thejimic, github: jimi-c On Thu, Dec 1, 2016 at 7:26 AM, Peter Burns <[email protected]> wrote: > Hi there, > > I posted this to the Ansible Project list but got no responses, perhaps > this is the better forum for it to be answered though, so I'm cross posting > it here to. > > 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), > ), > ) > 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 as desired: > 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 Development" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
