2017-10-27 05:44:50 +00:00
# Initialize
2021-07-30 08:01:12 +00:00
2017-10-27 05:44:50 +00:00
- name : ...IS BEGINNING ============================================
2020-09-17 15:15:33 +00:00
stat :
2021-07-30 08:01:12 +00:00
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
register : iiab_ini_test
2020-09-17 15:15:33 +00:00
2021-07-30 08:01:12 +00:00
# Higher-level purpose explained at the bottom of:
# https://github.com/iiab/iiab/blob/master/vars/default_vars.yml
2022-12-22 00:29:04 +00:00
- name : "Ansible just ran /etc/ansible/facts.d/local_facts.fact to set 15 vars -- here we extract 6 of those -- iiab_stage: {{ ansible_local.local_facts.stage }}, rpi_model: {{ ansible_local.local_facts.rpi_model }}, devicetree_model: {{ ansible_local.local_facts.devicetree_model }}, os_ver: {{ ansible_local.local_facts.os_ver }}, python_version: {{ ansible_local.local_facts.python_version }}, php_version: {{ ansible_local.local_facts.php_version }}"
2020-03-05 11:22:36 +00:00
set_fact :
2022-09-27 20:49:34 +00:00
iiab_stage : "{{ ansible_local.local_facts.stage }}"
2020-03-05 11:22:36 +00:00
rpi_model : "{{ ansible_local.local_facts.rpi_model }}"
2021-11-27 15:36:20 +00:00
devicetree_model : "{{ ansible_local.local_facts.devicetree_model }}"
2022-09-27 20:49:34 +00:00
os_ver : "{{ ansible_local.local_facts.os_ver }}"
2022-12-22 00:29:04 +00:00
python_version : "{{ ansible_local.local_facts.python_version }}"
php_version : "{{ ansible_local.local_facts.php_version }}"
2020-03-05 11:22:36 +00:00
2021-07-30 08:01:12 +00:00
# Initialize /etc/iiab/iiab.ini writing the 'location' and 'version' sections
# once and only once, to preserve the install date and git hash.
- name : Create {{ iiab_ini_file }}, if it doesn't exist
include_tasks : create_iiab_ini.yml
when : not iiab_ini_test.stat.exists
# 2021-07-30: The 'first_run' flag isn't much used anymore. In theory it's
2022-12-21 18:34:30 +00:00
# still used in 1-prep/tasks/hardware.yml for raspberry_pi.yml
#
2022-06-29 22:37:13 +00:00
# This needs to be reworked for 0-init speed, and overall understandability.
2021-07-30 08:01:12 +00:00
- name : Set first_run flag
set_fact :
first_run : True
when : not iiab_ini_test.stat.exists
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).
2022-07-06 07:57:10 +00:00
- name : Copy iiab-summary & iiab-diagnostics from /opt/iiab/iiab/scripts/ to /usr/bin/
2019-10-12 19:16:50 +00:00
copy :
2022-07-06 07:57:10 +00:00
src : "{{ iiab_dir }}/scripts/{{ item }}"
2019-10-12 19:16:50 +00:00
dest : /usr/bin/
2020-01-13 16:08:11 +00:00
mode : '0755'
2022-07-06 07:57:10 +00:00
with_items :
- iiab-summary
- iiab-diagnostics
2019-10-12 19:16:50 +00:00
2021-07-30 08:01:12 +00:00
- name : Create globally-writable directory /etc/iiab/diag (0777) so non-root users can run 'iiab-diagnostics'
2019-10-12 22:47:51 +00:00
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
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
2022-10-03 15:52:13 +00:00
when : not (rpi_model | regex_search('\\bW\\b')) # Ansible require double backslashes, e.g. with \b "word boundary" anchors: https://www.regular-expressions.info/wordboundaries.html https://stackoverflow.com/questions/56869119/ansible-regular-expression-to-match-a-string-and-extract-the-line/56869801#56869801
2020-01-21 21:01:57 +00:00
2022-12-30 09:09:46 +00:00
# 2022-12-30: Functionality moved to www_options/tasks/php-settings.yml
# - name: "Time Zone / TZ: Set symlink /etc/localtime to UTC if it doesn't exist?"
# include_tasks: tz.yml
2017-11-04 19:47:48 +00:00
2022-03-25 05:08:40 +00:00
- name : Set hostname / domain (etc) in various places
include_tasks : hostname.yml
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 :
2021-07-30 08:01:12 +00:00
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
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 }}"
2022-07-06 06:39:29 +00:00
- option : iiab_remote_url
value : "{{ ansible_local.local_facts.iiab_remote_url }}"
2018-02-13 01:25:41 +00:00
- option : runtime_branch
value : "{{ ansible_local.local_facts.iiab_branch }}"
- option : runtime_commit
value : "{{ ansible_local.local_facts.iiab_commit }}"
2022-06-25 23:53:58 +00:00
- option : iiab_recent_tag
value : "{{ ansible_local.local_facts.iiab_recent_tag }}"
2018-02-13 01:25:41 +00:00
- 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 }}"
2020-03-09 17:24:11 +00:00
- option : rpi_model
2020-03-04 23:02:01 +00:00
value : "{{ rpi_model }}"
2021-11-27 15:36:20 +00:00
- option : devicetree_model
value : "{{ devicetree_model }}"
2022-09-27 20:49:34 +00:00
- option : os_ver
value : "{{ os_ver }}"
2022-12-22 00:29:04 +00:00
- option : python_version
value : "{{ python_version }}"
- option : php_version
value : "{{ php_version }}"
2018-02-13 01:25:41 +00:00
- option : first_run
2019-05-24 08:54:00 +00:00
value : "{{ first_run }}"
2022-12-30 09:09:46 +00:00
# - option: local_tz # e.g. 'EDT' (summer) or 'EST' (winter) after Ansible interprets symlink /etc/localtime -- or 'UTC' if /etc/localtime doesn't exist
# value: "{{ local_tz }}"
# - option: etc_localtime.stdout # e.g. 'America/New_York' direct from symlink /etc/localtime -- or '' if /etc/localtime doesn't exist
# value: "{{ etc_localtime.stdout }}"
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 :
2021-07-30 08:01:12 +00:00
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
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 ======================================
2021-07-30 08:01:12 +00:00
meta : noop # Or use "command: echo" to force instantiation of vars e.g. "name: {{ var }}"