Request your help

Hi All,

Request your help, below is the explanation of the issue that i have facing

  • I have 2 task T1 and T1
  • T1 has to executed on SERVER1 ,2,3
  • T2 has to be executed only on SERVER1

My Inventory -1

[ALL]
SERVER1

SERVER2

SERVER3

[PART1]
SERVER2

[PART2]

SERVER3-XXX ansible_host=SERVER3

I am able to accomplish this by using the below code using when condition if my Inventory file(My Inventory -2) is as below

  • hosts: ALL

tasks:

  • name : T1
    shell: xxxxxxx
  • name : T2
    shell: xxxxxxx
    when: inventory_hostname not in groups.PART1|union(groups.PART2)

My Inventory -2

ALL]
SERVER1

SERVER2

SERVER3

[PART1]
SERVER2

[PART2]

SERVER3

**So request your help on how to accomplish this task when the Inventory file is structure is as "**My Inventory -1"

From,
Vino.B