2023-08-23 17:31:22 -04:00
|
|
|
- name: Determine if host is up at static IP
|
|
|
|
local_action: "command ping -c 1 {{ local_ip }}"
|
2023-08-21 17:19:29 -04:00
|
|
|
become: no
|
|
|
|
ignore_errors: true
|
|
|
|
changed_when: false
|
|
|
|
register: up_static
|
|
|
|
|
2023-08-23 17:31:22 -04:00
|
|
|
- name: Switch ansible_host to fallback
|
2023-08-21 17:19:29 -04:00
|
|
|
set_fact:
|
|
|
|
ansible_host: "{{ fallback_host }}"
|
2023-08-23 17:31:22 -04:00
|
|
|
when: up_static.rc != 0
|
2023-08-21 17:19:29 -04:00
|
|
|
|
2023-08-23 17:31:22 -04:00
|
|
|
- name: Switch ansible_host to static IP
|
2023-08-21 17:19:29 -04:00
|
|
|
set_fact:
|
2023-08-23 17:31:22 -04:00
|
|
|
ansible_host: "{{ local_ip }}"
|
2023-08-21 17:19:29 -04:00
|
|
|
when: up_static.rc == 0
|