-
-
Save myh-st/80e08292ecafa6fb2f0f76bc239966a8 to your computer and use it in GitHub Desktop.
block/rescue removes host from ansible_play_hosts when block fails, even when rescued!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
connection: local | |
gather_facts: no | |
tasks: | |
- debug: | |
var: ansible_play_hosts | |
- block: | |
- fail: | |
msg: "Failure" | |
when: | |
- "inventory_hostname == 'localhost'" | |
rescue: | |
- debug: | |
msg: "Success" | |
always: | |
- debug: | |
var: ansible_play_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment