2017-10-27 05:44:50 +00:00
# Initialize
- name : ...IS BEGINNING ============================================
2020-09-17 15:15:33 +00:00
stat :
path : "{{ iiab_env_file }}"
register : NewInstall
- name : Set first_run flag
set_fact :
first_run : True
when : not NewInstall.stat.exists
- name : Set top-level variables from local_facts for convenience
2020-03-05 11:22:36 +00:00
set_fact :
rpi_model : "{{ ansible_local.local_facts.rpi_model }}"
xo_model : "{{ ansible_local.local_facts.xo_model }}"
iiab_stage : "{{ ansible_local.local_facts.stage }}"
2018-07-23 12:05:13 +00:00
# We need to inialize the ini file and only write the location and version
# sections once and only once to preserve the install date and git hash.
2019-08-10 20:42:19 +00:00
- name : Create IIAB tools and {{ iiab_ini_file }}, if first_run
2017-11-09 10:51:07 +00:00
include_tasks : first_run.yml
2020-10-16 20:46:19 +00:00
when : first_run
2017-10-27 05:44:50 +00:00
2019-10-13 17:20:58 +00:00
# Copies the latest/known version of iiab-diagnostics into /usr/bin (so it can
# be run even if local source tree /opt/iiab/iiab is deleted to conserve disk).
2019-10-12 19:16:50 +00:00
- name : Copy /opt/iiab/iiab/scripts/iiab-diagnostics to /usr/bin/iiab-diagnostics
copy :
src : "{{ iiab_dir }}/scripts/iiab-diagnostics"
dest : /usr/bin/
2020-01-13 16:08:11 +00:00
mode : '0755'
2019-10-12 19:16:50 +00:00
2019-10-12 22:47:51 +00:00
- name : Create globally-writable directory /etc/iiab/diag so non-root users can run iiab-diagnostics
file :
state : directory
path : /etc/iiab/diag
2020-01-13 16:08:11 +00:00
mode : '0777'
2019-10-12 22:47:51 +00:00
2020-09-17 15:15:33 +00:00
- name : Re-read local_facts.facts from /etc/ansible/facts.d
setup :
filter : ansible_local
2020-01-23 21:23:55 +00:00
- name : Pre-check that IIAB's "XYZ_install" + "XYZ_enabled" vars (1) are defined, (2) are boolean-not-string variables, and (3) contain plausible values. Also checks that "XYZ_install" is True when "XYZ_installed" is defined.
2020-01-22 00:26:16 +00:00
include_tasks : validate_vars.yml
2020-01-21 21:01:57 +00:00
2018-07-23 12:05:13 +00:00
# Discover: do we have a gateway?
# If Ansible detects gateway, becomes WAN candidate.
2020-03-19 10:57:49 +00:00
- name : "Do we have a gateway? If so set discovered_wan_iface: {{ ansible_default_ipv4.alias }}"
2017-11-04 19:47:48 +00:00
set_fact :
2017-12-08 07:02:28 +00:00
discovered_wan_iface : "{{ ansible_default_ipv4.alias }}"
2017-11-04 19:47:48 +00:00
when : ansible_default_ipv4.gateway is defined
2018-11-02 23:24:15 +00:00
- name : "Verify gateway active: ping -c4 {{ ansible_default_ipv4.gateway }}"
2017-11-04 19:47:48 +00:00
shell : ping -c4 "{{ ansible_default_ipv4.gateway }}" | grep icmp_seq=4 | wc -l
when : discovered_wan_iface != "none"
register : gw_active_test
2020-03-19 10:57:49 +00:00
- name : If so, set gw_active, iiab_wan_iface to {{ discovered_wan_iface }}
2017-11-04 19:47:48 +00:00
set_fact :
2020-03-19 10:57:49 +00:00
iiab_wan_iface : "{{ discovered_wan_iface }}"
2017-12-08 07:02:28 +00:00
gw_active : True
2017-11-04 19:47:48 +00:00
when : discovered_wan_iface != "none" and gw_active_test.stdout == "1"
2020-03-19 10:57:49 +00:00
- name : Test with {{ iiab_wan_iface }} for Internet access ({{ iiab_download_url }}/heart-beat.txt)
2017-12-08 07:02:28 +00:00
get_url :
url : "{{ iiab_download_url }}/heart-beat.txt"
dest : /tmp/heart-beat.txt
2020-01-23 22:37:29 +00:00
#timeout: "{{ download_timeout }}"
2017-12-18 16:12:58 +00:00
# @jvonau recommends: 100sec is too much (keep 10sec default)
ignore_errors : True
2020-01-23 22:37:29 +00:00
#async: 10
#poll: 2
2017-11-04 19:47:48 +00:00
register : internet_access_test
2018-11-02 23:06:29 +00:00
- name : Set internet_available if download succeeded and not disregard_network
2017-11-04 19:47:48 +00:00
set_fact :
2017-12-08 07:02:28 +00:00
internet_available : True
2018-08-31 09:55:59 +00:00
when : not internet_access_test.failed and not disregard_network
2017-11-04 19:47:48 +00:00
2018-11-02 23:06:29 +00:00
- name : Remove downloaded Internet test file /tmp/heart-beat.txt
2017-12-08 07:02:28 +00:00
file :
path : /tmp/heart-beat.txt
state : absent
2017-11-04 19:47:48 +00:00
2018-07-23 12:05:13 +00:00
# Put all computed vars here so derive properly from any prior var file.
2017-11-04 19:47:48 +00:00
- name : If the TZ is not set in env, set it to UTC
2017-10-08 21:55:57 +00:00
include_tasks : tz.yml
2017-11-04 19:47:48 +00:00
2018-11-02 23:06:29 +00:00
- name : Set port 80 for Admin Console if not adm_cons_force_ssl
2017-11-04 19:47:48 +00:00
set_fact :
gui_port : 80
when : not adm_cons_force_ssl
2018-11-02 23:06:29 +00:00
- name : Set port 443 for Admin Console if adm_cons_force_ssl
2017-11-04 19:47:48 +00:00
set_fact :
gui_port : 443
2020-10-16 20:46:19 +00:00
when : adm_cons_force_ssl
2017-11-04 19:47:48 +00:00
2018-11-02 23:06:29 +00:00
- name : "Set iiab_fqdn: {{ iiab_hostname }}.{{ iiab_domain }}"
2017-11-06 22:45:06 +00:00
set_fact :
2017-12-08 07:02:28 +00:00
iiab_fqdn : "{{ iiab_hostname }}.{{ iiab_domain }}"
FQDN_changed : False
2017-11-06 22:45:06 +00:00
2018-11-02 23:06:29 +00:00
- name : Set FQDN_changed when iiab_fqdn != ansible_fqdn ({{ ansible_fqdn }})
2017-11-06 22:45:06 +00:00
set_fact :
2017-12-08 07:02:28 +00:00
FQDN_changed : True
2017-11-06 22:45:06 +00:00
when : iiab_fqdn != ansible_fqdn
2018-07-27 20:03:34 +00:00
- name : Set hostname if FQDN_changed
2018-05-17 16:42:33 +00:00
include_tasks : hostname.yml
2020-10-16 20:46:19 +00:00
when : FQDN_changed
2018-05-17 16:42:33 +00:00
2018-10-15 11:01:09 +00:00
- name : Add 'runtime' variable values to {{ iiab_ini_file }}
2017-12-08 07:02:28 +00:00
ini_file :
2018-10-15 09:05:20 +00:00
dest : "{{ iiab_ini_file }}"
2017-12-08 07:02:28 +00:00
section : runtime
option : "{{ item.option }}"
2020-01-12 02:41:37 +00:00
value : "{{ item.value | string }}"
2017-11-04 19:47:48 +00:00
with_items :
2018-02-13 01:25:41 +00:00
- option : iiab_stage
value : "{{ iiab_stage }}"
- option : iiab_base_ver
value : "{{ iiab_base_ver }}"
- option : iiab_revision
value : "{{ iiab_revision }}"
- option : runtime_branch
value : "{{ ansible_local.local_facts.iiab_branch }}"
- option : runtime_commit
value : "{{ ansible_local.local_facts.iiab_commit }}"
- option : runtime_date
value : "{{ ansible_date_time.iso8601 }}"
- option : ansible_version
value : "{{ ansible_local.local_facts.ansible_version }}"
- option : kernel
value : "{{ ansible_kernel }}"
- option : memory_mb
value : "{{ ansible_memtotal_mb }}"
- option : swap_mb
value : "{{ ansible_swaptotal_mb }}"
- option : product_id
value : "{{ ansible_product_uuid }}"
- option : gw_active
2019-05-24 08:54:00 +00:00
value : "{{ gw_active }}"
2018-02-13 01:25:41 +00:00
- option : internet_available
2019-05-24 08:54:00 +00:00
value : "{{ internet_available }}"
2020-03-09 17:24:11 +00:00
- option : rpi_model
2020-03-04 23:02:01 +00:00
value : "{{ rpi_model }}"
2018-02-13 01:25:41 +00:00
- option : first_run
2019-05-24 08:54:00 +00:00
value : "{{ first_run }}"
2018-02-13 01:25:41 +00:00
- option : local_tz
2019-05-24 08:54:00 +00:00
value : "{{ local_tz }}"
2019-01-02 02:21:29 +00:00
- option : no_NM_reload
value : "{{ no_NM_reload }}"
- option : is_F18
value : "{{ is_F18 }}"
2018-02-13 01:25:41 +00:00
- option : FQDN_changed
2019-05-24 08:54:00 +00:00
value : "{{ FQDN_changed }}"
2017-11-04 19:47:48 +00:00
2018-10-15 11:01:09 +00:00
- name : Add 'runtime' variable 'is_VM' value if defined, to {{ iiab_ini_file }}
2017-12-08 07:02:28 +00:00
ini_file :
2018-10-15 09:05:20 +00:00
dest : "{{ iiab_ini_file }}"
2017-12-08 07:02:28 +00:00
section : runtime
option : "{{ item.option }}"
2020-01-12 02:41:37 +00:00
value : "{{ item.value | string }}"
2017-11-04 19:47:48 +00:00
with_items :
2018-02-13 01:25:41 +00:00
- option : is_VM
2019-05-24 08:54:00 +00:00
value : "yes"
2017-11-04 19:47:48 +00:00
when : is_VM is defined
2018-10-15 09:05:20 +00:00
- name : STAGE 0 HAS COMPLETED ======================================
2018-10-15 09:40:07 +00:00
meta : noop