This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
homeserver-ansible/tasks/set_host.yml

17 lines
412 B
YAML
Raw Normal View History

2022-03-02 19:58:31 -05:00
- name: Determine if host is up at static IP
local_action: "command ping -c 1 {{ local_ip }}"
become: no
ignore_errors: true
2022-03-04 07:30:52 -05:00
changed_when: false
2022-03-02 19:58:31 -05:00
register: up_static
- name: Switch ansible_host to fallback IP
set_fact:
ansible_host: "{{ fallback_host }}"
when: up_static.rc != 0
- name: Switch ansible_host to static IP
set_fact:
ansible_host: "{{ local_ip }}"
when: up_static.rc == 0