I am working on getting everything on github but for a more specific 
example I have this:

applications:
  apps:
    - name: web1
      type: wordpress
      path: /var/www/web1
    - name: web2
      type: symfony
      path: /var/www/web2
    - name: web3
      type: wordpress
      path: /var/www/web3

- { role: wordpress }
- { role: symfony }
- { role: laravel }
- { role: phpbb }
- { role: yii }

Inside the roles I still have to do with_items: applications.apps when: 
item.type == wordpress

If I have dozens of these "applications", they would all be processed 
unless I can add something like process wordpress sites, when a wordpress 
application exists, etc. By being able to skip over all the roles and all 
the tasks within the role if they are not applicable. 

I am open for any ideas, the goal is just to either dynamically include the 
roles that are in the yaml, or skip over the ones that are not. 


On Thursday, December 5, 2013 3:17:15 PM UTC-7, Michael DeHaan wrote:
>
> 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]<javascript:>
> > 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] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Michael DeHaan <[email protected] <javascript:>>
> 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.

Reply via email to