# Initialize - name: ...IS BEGINNING ============================================ stat: path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini register: iiab_ini_test # Higher-level purpose explained at the bottom of: # https://github.com/iiab/iiab/blob/master/vars/default_vars.yml - name: "Ansible just ran /etc/ansible/facts.d/local_facts.fact to set 11 vars -- here we extract 3 of those -- rpi_model: {{ ansible_local.local_facts.rpi_model }}, devicetree_model: {{ ansible_local.local_facts.devicetree_model }}, iiab_stage: {{ ansible_local.local_facts.stage }}" set_fact: rpi_model: "{{ ansible_local.local_facts.rpi_model }}" devicetree_model: "{{ ansible_local.local_facts.devicetree_model }}" #xo_model: "{{ ansible_local.local_facts.xo_model }}" iiab_stage: "{{ ansible_local.local_facts.stage }}" # 2020-10-29: Appears no longer nec (see 3 above ansible_local.local_facts.*) #- name: Re-read local_facts.facts from /etc/ansible/facts.d # setup: # filter: ansible_local # 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 # still used in these 2 places: # (1) roles/1-prep/tasks/main.yml for raspberry_pi.yml # (2) roles/network/tasks/named.yml for "Stop named before copying files" # In practice however, it's no longer important, and might be reconsidered? - name: Set first_run flag set_fact: first_run: True when: not iiab_ini_test.stat.exists # 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). - name: Copy /opt/iiab/iiab/scripts/iiab-diagnostics to /usr/bin/iiab-diagnostics copy: src: "{{ iiab_dir }}/scripts/iiab-diagnostics" dest: /usr/bin/ mode: '0755' - name: Create globally-writable directory /etc/iiab/diag (0777) so non-root users can run 'iiab-diagnostics' file: state: directory path: /etc/iiab/diag mode: '0777' - 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. include_tasks: validate_vars.yml - name: "Time Zone / TZ: Set symlink /etc/localtime to UTC if it doesn't exist?" include_tasks: tz.yml - name: Test Gateway + Test Internet + Set new hostname/domain (hostname.yml) if nec + Set 'gui_port' to 80 or 443 for Admin Console include_tasks: network.yml - name: Add 'runtime' variable values to {{ iiab_ini_file }} ini_file: path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini section: runtime option: "{{ item.option }}" value: "{{ item.value | string }}" with_items: - 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: gw_active value: "{{ gw_active }}" - option: internet_available value: "{{ internet_available }}" - option: rpi_model value: "{{ rpi_model }}" - option: devicetree_model value: "{{ devicetree_model }}" - option: first_run value: "{{ first_run }}" - 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 }}" #- option: no_NM_reload # value: "{{ no_NM_reload }}" #- option: is_F18 # value: "{{ is_F18 }}" - option: FQDN_changed value: "{{ FQDN_changed }}" - name: Add 'runtime' variable 'is_VM' value if defined, to {{ iiab_ini_file }} ini_file: path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini section: runtime option: "{{ item.option }}" value: "{{ item.value | string }}" with_items: - option: is_VM value: "yes" when: is_VM is defined - name: STAGE 0 HAS COMPLETED ====================================== meta: noop # Or use "command: echo" to force instantiation of vars e.g. "name: {{ var }}"