I’m playing with my module and would like to cram most operations into one transaction under ‘with_items’ according to the docs ‘yum’ and ‘apt’ modules can combine multiple operations generated by ‘with_items’ into one. However I’m a bit puzzled as to what is causing it to behave that way.
I expect /tmp/foo to contain 1,2,3 (it seems like that is how yum is receiving it’s list of packages) but I end up with ‘3’ every time (result of file being overwritten 2 times). I’m definitely missing something, but what?
There are some other internals inside of ansible/runner/init.py that do the behind the scenes magic required for the with_items stuff that is done for yum and apt:
last two result in a simple list iteration, while the first one passes dictionary this should help with my module building… unless somebody is going to point out a better way/inapropriateness of my approach
I ran into this problem today. I found with_items but with single module call discussed on ansible-devel. I know this thread is old, but has anything changed? I see no discussion of Brian Coca’s wantarray patch on ansible-devel. I see TaskExecutor replaced Runner and that lines 53-55 still refer to a constant when deciding whether to squash loops into a single call.
If this was StackExchange I’d upvote. Instead, I’ll leave this note of endorsement. This example is exactly what I was looking for! It isn’t specific to packaging at all. It’s a general purpose solution to passing arguments into modules. Too bad apt, yum, and pkgng have already been hacked. But let the madness not extend further! Module interfaces shouldn’t rely on with_items. Instead, I’ll be using complex arguments.
it includes a bit more than the 'squash' feature, for now we just
made it configurable so users can enable/disable it by module, going
forward i would like to make it per task as in the example in the
ticket.