mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 19:52:06 +00:00
70 lines
2.7 KiB
YAML
70 lines
2.7 KiB
YAML
- name: Do we have a gateway? If 'ip route' specifies a default route, Ansible parses details here...
|
|
debug:
|
|
var: ansible_default_ipv4
|
|
|
|
- name: "If above ansible_default_ipv4.gateway is defined, set WAN candidate 'discovered_wan_iface: {{ ansible_default_ipv4.alias }}' -- using ansible_default_ipv4.alias"
|
|
set_fact:
|
|
discovered_wan_iface: "{{ ansible_default_ipv4.alias }}"
|
|
when: ansible_default_ipv4.gateway is defined
|
|
|
|
- name: "Verify gateway active: ping -c4 {{ ansible_default_ipv4.gateway }} -- using ansible_default_ipv4.gateway"
|
|
shell: ping -c4 "{{ ansible_default_ipv4.gateway }}" | grep icmp_seq=4 | wc -l
|
|
register: gw_active_test
|
|
when: discovered_wan_iface != "none"
|
|
|
|
- name: "If gateway responded, set 'gw_active: True' and 'iiab_wan_iface: {{ discovered_wan_iface }}' -- using discovered_wan_iface"
|
|
set_fact:
|
|
iiab_wan_iface: "{{ discovered_wan_iface }}"
|
|
gw_active: True
|
|
when: discovered_wan_iface != "none" and gw_active_test.stdout == "1"
|
|
|
|
|
|
- name: 'Test for Internet access, using: {{ iiab_download_url }}/heart-beat.txt'
|
|
get_url:
|
|
url: "{{ iiab_download_url }}/heart-beat.txt"
|
|
dest: /tmp/heart-beat.txt
|
|
#timeout: "{{ download_timeout }}"
|
|
# @jvonau recommends: 100sec is too much (keep 10sec default)
|
|
ignore_errors: True
|
|
#async: 10
|
|
#poll: 2
|
|
register: internet_access_test
|
|
|
|
- name: "Set 'internet_available: True' if above download succeeded AND not disregard_network"
|
|
set_fact:
|
|
internet_available: True # Initialized to 'False' in 0-init/defaults/main.yml
|
|
when: not internet_access_test.failed and not disregard_network
|
|
|
|
- name: Remove downloaded Internet test file /tmp/heart-beat.txt
|
|
file:
|
|
path: /tmp/heart-beat.txt
|
|
state: absent
|
|
|
|
|
|
- name: "Set 'iiab_fqdn: {{ iiab_hostname }}.{{ iiab_domain }}'"
|
|
set_fact:
|
|
iiab_fqdn: "{{ iiab_hostname }}.{{ iiab_domain }}"
|
|
FQDN_changed: False
|
|
|
|
- name: Set hostname / domain (etc) in various places -- if iiab_fqdn != ansible_fqdn ({{ ansible_fqdn }})
|
|
include_tasks: hostname.yml
|
|
when: iiab_fqdn != ansible_fqdn
|
|
|
|
# 2021-07-30: FQDN_changed isn't used as in the past -- its remaining use is
|
|
# for {named, dhcpd, squid} in roles/network/tasks/main.yml -- possibly it
|
|
# should be reconsidered? See PR #2876: roles/network might become optional?
|
|
- name: "Also set 'FQDN_changed: True' -- if iiab_fqdn != ansible_fqdn ({{ ansible_fqdn }})"
|
|
set_fact:
|
|
FQDN_changed: True
|
|
when: iiab_fqdn != ansible_fqdn
|
|
|
|
|
|
- name: "Set 'gui_port: 80' for Admin Console if not adm_cons_force_ssl"
|
|
set_fact:
|
|
gui_port: 80
|
|
when: not adm_cons_force_ssl # 2021-07-30: default_vars.yml initializes 'adm_cons_force_ssl: False'
|
|
|
|
- name: "Set 'gui_port: 443' for Admin Console if adm_cons_force_ssl"
|
|
set_fact:
|
|
gui_port: 443
|
|
when: adm_cons_force_ssl
|