diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index a12c91156..27de31b64 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -7,12 +7,13 @@ # 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 }}" +- name: "Ansible just ran /etc/ansible/facts.d/local_facts.fact to set 14 vars -- here we extract 5 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_ver: {{ ansible_local.local_facts.python_ver }}" set_fact: 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_ver: "{{ ansible_local.local_facts.python_ver }}" # Initialize /etc/iiab/iiab.ini writing the 'location' and 'version' sections # once and only once, to preserve the install date and git hash. @@ -21,9 +22,8 @@ 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/hardware.yml for raspberry_pi.yml -# (2) roles/network/tasks/named.yml for "Stop named before copying files" +# still used in 1-prep/tasks/hardware.yml for raspberry_pi.yml +# # This needs to be reworked for 0-init speed, and overall understandability. - name: Set first_run flag set_fact: @@ -96,6 +96,8 @@ value: "{{ devicetree_model }}" - option: os_ver value: "{{ os_ver }}" + - option: python_ver + value: "{{ python_ver }}" - 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 diff --git a/roles/lokole/tasks/install.yml b/roles/lokole/tasks/install.yml index b472ebdd3..82b1c9cf4 100644 --- a/roles/lokole/tasks/install.yml +++ b/roles/lokole/tasks/install.yml @@ -2,10 +2,10 @@ # https://github.com/iiab/iiab/blob/master/roles/www_base/templates/iiab-refresh-wiki-docs.sh#L51-L52 -- name: "Install 8 packages for Lokole: python3, python3-pip, python3-venv, python3-dev, python3-bcrypt, libffi-dev, libssl-dev, libopenjp2-7" +- name: Install 14 packages for Lokole apt: name: - - python3 + #- python3 # 2022-12-21: IIAB pre-req, see scripts/local_facts.fact - python3-pip - python3-venv - python3-dev @@ -55,12 +55,19 @@ extra_args: --no-cache-dir # To avoid caching issues e.g. soon after new releases hit https://pypi.org/project/opwen-email-client/ when: lokole_commit is undefined and lokole_version is undefined -- name: Compile translations +# 2022-12-21: Dynamic callout to Python moved to scripts/local_facts.fact (Python 3 is now a mandatory IIAB pre-req) +# - name: Compile translations +# shell: | +# python_version=$(python3 -c 'from sys import version_info; print("%s.%s" % (version_info.major, version_info.minor));';) +# {{ lokole_venv }}/bin/pybabel compile -d {{ item }}/translations +# with_items: +# - "{{ lokole_venv }}/lib/python${python_version}/site-packages/opwen_email_client/webapp" + +- name: Compile translations for Python {{ python_ver }} shell: | - python_version=$(python3 -c 'from sys import version_info; print("%s.%s" % (version_info.major, version_info.minor));';) {{ lokole_venv }}/bin/pybabel compile -d {{ item }}/translations with_items: - - "{{ lokole_venv }}/lib/python${python_version}/site-packages/opwen_email_client/webapp" + - "{{ lokole_venv }}/lib/python{{ python_ver }}/site-packages/opwen_email_client/webapp" - name: Create system {{ lokole_user }} user ansible.builtin.user: diff --git a/roles/postgresql/tasks/install.yml b/roles/postgresql/tasks/install.yml index 3fa1a95d0..df2918a32 100644 --- a/roles/postgresql/tasks/install.yml +++ b/roles/postgresql/tasks/install.yml @@ -6,13 +6,18 @@ - python3-psycopg2 # For Ansible modules {postgresql_db, postgresql_user} in Ansible collection community.postgresql -- used in moodle/tasks/install.yml state: present +- name: Run shell command "pg_config --version" to extract MAJOR version numner -- strip off MINOR/PATCH version number(s) + shell: pg_config --version | sed 's/^[^0-9]*//' | sed 's/[^0-9].*//' + register: pg_config_version + +- name: 'Dynamically set Ansible var "postgresql_version: {{ pg_config_version.stdout }}"' + set_fact: + postgresql_version: "{{ pg_config_version.stdout }}" + - name: Install /etc/systemd/system/postgresql-iiab.service from template (0644 by default) template: src: postgresql-iiab.service dest: /etc/systemd/system/postgresql-iiab.service - # owner: root - # group: root - # mode: '0644' - name: Create PostgreSQL data dir /library/pgsql-iiab, owned by postgres:postgres (0700) file: diff --git a/scripts/local_facts.fact b/scripts/local_facts.fact index ce796fcc3..236e08619 100755 --- a/scripts/local_facts.fact +++ b/scripts/local_facts.fact @@ -11,7 +11,9 @@ STAGE=0 OS="none" -VERSION_ID="none" # This var's combined with the above, before being output +VERSION_ID="none" # Temp var, for: OS_VER="$OS-$VERSION_ID" +OS_VER="none" +PYTHON_VER="none" IIAB_REMOTE_URL="none" IIAB_BRANCH="none" IIAB_COMMIT="none" @@ -63,6 +65,7 @@ OS_VER="$OS-$VERSION_ID" #"ubuntu-17" | \ #"ubuntu-18" | \ #"ubuntu-19" | \ + #"ubuntu-2004" | \ #"ubuntu-2104" | \ #"ubuntu-2110" | \ #"centos-7" | \ @@ -76,7 +79,6 @@ OS_VER="$OS-$VERSION_ID" case $OS_VER in "debian-11" | \ "debian-12" | \ - "ubuntu-2004" | \ "ubuntu-2204" | \ "ubuntu-2210" | \ "ubuntu-2304" | \ @@ -123,6 +125,13 @@ tmp=$(ansible --version) && #ANSIBLE_VERSION=$(echo "$tmp" | head -1 | awk '{print $2}') #ANSIBLE_VERSION=$(echo "$tmp" | head -1 | sed -e 's/.* //') +if tmp=$(python3 -c 'from sys import version_info; print("%s.%s" % (version_info.major, version_info.minor));'); then + PYTHON_VER=$tmp +else + echo -e "\e[1m\nPython 3 is REQUIRED for Internet-in-a-Box. You might want to run:\n\nsudo apt install python3\n\e[0m" + exit 1 +fi + # THE LAST 3 BELOW ARE DIFFERENT as "systemctl is-enabled" unhelpfully returns # the same error code (i.e. 1) REGARDLESS whether the service is (A) disabled @@ -159,5 +168,6 @@ cat <