You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
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
Brian Coca
unread,
Jun 1, 2015, 5:46:20 PM6/1/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message