On 3/17/20 11:04 AM, דודו דודו wrote:
> I have a partial success that I can not figure what is the problem.
> I have 2 tasks, one not in group and the other in group 
> 
> The first task is running as required, the second task is skipping all groups 
> - Can not understand why 
> 
> - name: install java-11-openjdk' packages
>   yum:
>     name: ['java-11-openjdk']
>     state: latest
>   when:
>     - inventory_hostname not in groups.kafka
>     - inventory_hostname not in groups.kafka_master
> 
> 
> - name: install java-8-openjdk' packages
>   yum:
>     name: ['java-1.8.0-openjdk']
>     state: latest
>   when:
>     - inventory_hostname in groups.kafka
>     - inventory_hostname in groups.kafka_master

That is because both conditions are combined with an AND, so I can't be true.

You can try or (untested):

when: inventory_hostname in groups.kafka or inventory_hostname in 
groups.kafka_master

Regards
        Racke

> 
> 
> 
> 
> 
> TASK [install java-11-openjdk' packages]
> **********************************************************************************************************************************************************************************
> ok: [10.201.51.34]
> skipping: [10.201.51.39]
> skipping: [10.201.51.40]
> skipping: [10.201.51.41]
> ok: [10.201.51.38]
> ok: [10.201.51.37]
> ok: [10.201.51.42]
> ok: [10.201.51.36]
> skipping: [10.201.51.44]
> skipping: [10.201.51.45]
> skipping: [10.201.51.46]
> ok: [10.201.51.30]
> ok: [10.201.51.31]
> ok: [10.201.51.35]
> ok: [10.201.51.32]
> ok: [10.201.51.33]
> ok: [10.201.51.5]
> 
> TASK [install java-8-openjdk' packages]
> ***********************************************************************************************************************************************************************************
> skipping: [10.201.51.42]
> skipping: [10.201.51.34]
> skipping: [10.201.51.36]
> skipping: [10.201.51.37]
> skipping: [10.201.51.38]
> skipping: [10.201.51.39]
> skipping: [10.201.51.40]
> skipping: [10.201.51.41]
> skipping: [10.201.51.30]
> skipping: [10.201.51.31]
> skipping: [10.201.51.32]
> skipping: [10.201.51.44]
> skipping: [10.201.51.45]
> skipping: [10.201.51.46]
> skipping: [10.201.51.5]
> skipping: [10.201.51.35]
> skipping: [10.201.51.33]
> 
> On Tuesday, March 17, 2020 at 9:14:39 AM UTC+2, Albert Short wrote:
> 
>     This is one option I have used in the past
> 
> 
>     On Tuesday, 17 March 2020 08:33:46 UTC+2, דודו דודו wrote:
> 
>         HI, 
> 
>         I have a task that runs only on servers that are under Kafka group. 
> How can i run the task on Kafka and
>         Webserver groups only.
> 
>         Thanks
> 
>         - name: install java-8-openjdk' packages
>           yum:
>             name: ['java-1.8.0-openjdk']
>             state: latest
>             when: "'kafka' in group_names"
> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/81d98394-39d7-4ec9-90bc-97f024638073%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/81d98394-39d7-4ec9-90bc-97f024638073%40googlegroups.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/276dd785-d5b9-5682-c847-f8b2b2fc24d0%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to