-
-
Save vic501/9e3d837fe97950b8138b5da671ac21d3 to your computer and use it in GitHub Desktop.
Ansible ignore all future tasks for unreachable hosts
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
--- | |
- name: Identify reachable hosts | |
hosts: all | |
connection: local | |
gather_facts: false | |
tasks: | |
- block: | |
- name: determine hosts that are reachable | |
ansible.builtin.wait_for_connection: | |
timeout: 10 | |
vars: | |
ansible_connection: ssh | |
- name: add devices with connectivity to the "reachable" group | |
ansible.builtin.group_by: | |
key: reachable | |
rescue: | |
- name: debug print unreachable host(s) | |
ansible.builtin.debug: msg="cannot connect to {{ inventory_hostname }}" | |
- name: Provision reachable hosts | |
hosts: reachable | |
tasks: | |
- name: debug print reachable host(s) | |
ansible.builtin.debug: msg="{{ inventory_hostname }} is reachable" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment