Thanks Matt. 

Both of these work as expected.  But, is there a more efficient way of 
stringing together a bunch of ORs?  Rather than using...

when: inventory_hostname in groups.hadoop OR inventory_hostname in 
groups.report OR inventory_hostname in groups.app OR inventory_hostname in 
groups.web ....

-Mike
On Thursday, January 15, 2015 at 5:46:01 PM UTC-8, Matt Martz wrote:
>
> Your "when" statement is a little off.
>
> The following [ groups.hadoop , groups.report ] would produce something 
> like [[hadoop1, hadoop2], [report1, report2]] so it would be able to match 
> like you are expecting.
>
> I think what you want is probably something more like:
>
> when: inventory_hostname in groups.hadoop or inventory_hostname in 
> groups.report
>
> Or maybe even:
>
> when: inventory_hostname in groups.hadoop|union(groups.report)
>
> On Thu, Jan 15, 2015 at 7:19 PM, Michael Liu <[email protected] 
> <javascript:>> wrote:
>
>> Trying to add a ssh key when a inventory_hostname belong to certain 
>> groups.  I would assume that the following is saying when 
>> inventory_hostname belongs to group hadoop OR report.
>>
>> when: inventory_hostname in [ groups.hadoop , groups.report ]
>>
>>
>> ISSUE: The following task is skipping, even though the host belongs to 
>> group report.
>>
>> - name: add root authorized keys for test key
>>   authorized_key: user=root key="{{ item }}"
>>   when: inventory_hostname in [ groups.hadoop , groups.report ]
>>   with_items:
>>     - "ssh-rsa 
>> ZzzzzzHV+drdA0PWHRaDw1fqtM/PElGVbysuNCxFJ9JUBebnsbvAqNFQyMDEweMe5xHV+drdA0PWHRaDw1fqtM/PElGVbysuNCxFJ9JUBebnsbvAqNFQyMDEweMe5xHV+drdA0PWHRaDw1fqtM/PElGVbysuNCxFJ9JUBebnsbvAqNFQyMDEweMe5xHV+drdA0PWHRaDw1fqtM/PElGVbysuNCxFJ9JUBebnsbvAqNFQyMDEweMe5x
>>  
>> testkey"
>>
>>
>> TASK: [provision_server | add root authorized keys for test key] 
>> ************
>> skipping: [server1] => 
>> (item=ssh-rsa 
>> ZzzzzzHV+drdA0PWHRaDw1fqtM/PElGVbysuNCxFJ9JUBebnsbvAqNFQyMDEweMe5xHV+drdA0PWHRaDw1fqtM/PElGVbysuNCxFJ9JUBebnsbvAqNFQyMDEweMe5xHV+drdA0PWHRaDw1fqtM/PElGVbysuNCxFJ9JUBebnsbvAqNFQyMDEweMe5xHV+drdA0PWHRaDw1fqtM/PElGVbysuNCxFJ9JUBebnsbvAqNFQyMDEweMe5x
>>  
>> testkey)
>>
>> Is there something wrong with with my syntax for an OR condition for host 
>> groups?
>>
>> Thanks!
>>
>> -- 
>> 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:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/70c2f317-6804-45cc-9194-85ce3cfc6fda%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/70c2f317-6804-45cc-9194-85ce3cfc6fda%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Matt Martz
> @sivel
> sivel.net
>  

-- 
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/724a58b9-4525-4fb5-81d4-c1fa9773bcd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to