If there are no hosts added to add host, subsequent plays should be skipped. Please let me know how to provide when condition for this
- name:
hosts: rchadm01
vars_files:
- var.yml
tasks:
- name:
add_host:
name: "{{ decom_host }}"
groups: decom_host_group
- import_playbook: sub_plays/play2.yml
when: '"decom_host_group" not in group_names'