i think this is the droid you are looking for: http://jinja.pocoo.org/docs/dev/templates/#map
On Mon, Jun 1, 2015 at 5:12 PM, Patrick Glomski <[email protected]> wrote: > When running a task with multiple items using 'with_items', the results are > registered in a variable under 'results' as a list. Is there any way to > apply a filter such as 'any' or 'all' to that list in a conditional on the > next task's execution? The only way I can do something currently is to > perform the following task several times (once for every item in the list > that evaluates as true for my condition). I'd rather not notify a handler, > because the following tasks depend on this task being evaluated. > > simple example I just made up to illustrate what I want: > > ############################################### > - name: run a script to configure network interfaces > lineinfile: > - dest: /etc/sysconfig/network-scripts/ifcfg-{{item}}" > - ... > - some arbitrary keywords... > - ... > with_items: > - eth0 > - eth1 > register: configured_network > > - name: restart the network service. what I currently do (potentially > restarts network twice) > service: name=network state=restarted > when: item.changed == true > with_items: configured_network.results > > - name: mount a share that is on the newly configured network and wasn't > available before > mount: ... > ############################################### > > I would like to restart the service ONE time on check. Something like: > > - name: restart the network service > service: name=network state=restarted > when: any(item.changed == true for item in configured_network.results) > > Apologies for the long-winded examples, but I didn't know how else to convey > what I'm interested in. Is this kind of functionality possible??? > > Thanks, > Patrick > > > -- > 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/602ca00d-f879-4380-8d8c-60e15663aa29%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Brian Coca -- 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/CAJ5XC8nsu7O%2B%3Dtr%3DJYZjm3SPQJcXCCBXBWudfyExaOnritWZ3Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
