Run play only if host is reachable

From MyWiki
Revision as of 17:39, 8 October 2019 by George2 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Create a new group of the reachable hosts:

- name: check reachable hosts
  hosts: all
  gather_facts: no
  tasks:
    - command: ping -c1 {{ inventory_hostname }}
      delegate_to: localhost
      register: ping_result
      ignore_errors: yes
    - group_by: key=reachable
      when: ping_result|success