1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
- hosts: all gather_facts: false tasks: - block: - fail: when: inventory_hostname == 'host1' rescue: - block: - fail: when: inventory_hostname == 'host1' - assert: that: - "'host1' not in ansible_play_hosts" - "'host1' not in ansible_play_batch" success_msg: PASSED