If your applications are roles I don't think you would need to check the type of the application inside the role, because the role would just contain what it would need to do.
I think I'd need to see a more specific example of that arbitrary task to provide a suggestion or to understand more about what you are doing. On Thu, Dec 5, 2013 at 5:00 PM, Patrick Heeney <[email protected]>wrote: > Right now I have yaml that look like: > > applications: > - name: app1 > type: type1 > - name: app2 > type: type2 > - name: app3 > type: type1 > > With lots of roles that look like this: > > - { role: 'type1' } > - { role: 'type2' } > - { role: 'type3' } > > And inside these roles on every task I have to do something like this: > > - name: task > with_items: applications > when: item.type == type1 > > The issue is that is has to run every one of these roles and all the tasks > within it. It complicates things having to add the when item.type > == type1 to every task within the role. I am trying to figure out a way so > that these roles are not even included if they do not exist in the list. > Something like: > > - { role: 'app1', when: applications|exist('type', 'type1') } > > - { role: 'app1', when: applications.type == type1 } > > - { role:"{{ item.type }}", data: {{ item }}, with_items: applications, > when: item.type == type1 } > > -- > 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]. > For more options, visit https://groups.google.com/groups/opt_out. > -- Michael DeHaan <[email protected]> CTO, AnsibleWorks, Inc. http://www.ansibleworks.com/ -- 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]. For more options, visit https://groups.google.com/groups/opt_out.
