How to make ansible ignore a group name in hosts file if it has no ip?

I have 2 groups created in hosts file as given below. I have a playbook consisting of 2 plays - the 1st play will be executed on IP in ‘ACTIVEFIREWALL’ group and 2nd play will be executed on IP in ‘STANDBYFIREWALL’ group.

Many a times, i have no ip to be give for ‘STANDBYFIREWALL’ group (so the ip portion remains blank but everything else mentioned below remains on hosts file). So the 2nd play just stops and does nothing until timeout. However when i delete the entire ‘STANDBYFIREWALL’ group from inventory file, Ansible ignores the 2nd play containing ‘STANDBYFIREWALL’ group and moves on.

Is there any ways i can make Ansible to move on without deleting STANDBYFIREWALL group from hosts file when there is no IP to give?

[ACTIVEFIREWALL]

FW1 ansible_host=10.224.240.241

[ACTIVEFIREWALL:vars]

ansible_user=username

ansible_ssh_pass=password

[STANDBYFIREWALL]

FW2 ansible_host=10.224.240.244

[STANDBYFIREWALL:vars]

ansible_user=username

ansible_ssh_pass=password

Thanks,

Vikram

Hi,

I am the OP and i just got an idea for my above question. Do you think below script might solve my issue?

  • name: PLAYBOOK FOR STANDBY FIREWALL UPGRADE

    hosts: STANDBYFIREWALL

    serial: 1

    gather_facts: false

    connection: network_cli

    tasks:

    • name: End playbook if connection IP is not defined

      meta: end_host

      when: {{ ansible_host }} is not defined

Thanks,
Vikram