From 8906204ebb8f8eae1d64dc8aeed7a7faa86a6219 Mon Sep 17 00:00:00 2001 From: Chris Croome <chris@webarchitects.co.uk> Date: Mon, 30 Sep 2024 14:28:55 +0100 Subject: [PATCH] update for ANSIBLE_INJECT_FACT_VARS: "0" --- .gitlab-ci.yml | 1 + .pre-commit-config.yaml | 2 +- molecule/bookworm_cli/converge.yml | 12 ++++++------ molecule/bookworm_fpm/converge.yml | 12 ++++++------ molecule/default/converge.yml | 12 ++++++------ tasks/apt.yml | 6 +++--- tasks/check_vars.yml | 6 +++--- tasks/file_absent.yml | 2 +- tasks/file_edited.yml | 2 +- tasks/file_templated.yml | 2 +- tasks/pkg.yml | 2 +- templates/php.pref.j2 | 6 +++--- 12 files changed, 33 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3da0d10..bb09c95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,6 +13,7 @@ variables: ANSIBLE_DIFF_ALWAYS: "1" ANSIBLE_DISPLAY_SKIPPED_HOSTS: "0" ANSIBLE_FORCE_COLOR: "1" + ANSIBLE_INJECT_FACT_VARS: "0" ANSIBLE_REMOTE_TMP: "/tmp" ANSIBLE_SHELL_ALLOW_WORLD_READABLE_TEMP: "1" DEBIAN_FRONTEND: noninteractive diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ceda226..f1f0828 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,7 @@ repos: - VARIABLES.md # https://github.com/ansible/ansible-lint/releases - repo: https://github.com/ansible/ansible-lint.git - rev: v24.9.0 + rev: v24.9.2 hooks: - id: ansible-lint name: Ansible Lint diff --git a/molecule/bookworm_cli/converge.yml b/molecule/bookworm_cli/converge.yml index 5279618..b0a19c4 100644 --- a/molecule/bookworm_cli/converge.yml +++ b/molecule/bookworm_cli/converge.yml @@ -18,17 +18,17 @@ ansible_python_interpreter: /usr/bin/python3 tasks: - - name: Debug ansible_effective_user_id + - name: Debug ansible_facts.effective_user_id ansible.builtin.debug: - var: ansible_effective_user_id + var: ansible_facts.effective_user_id - - name: Debug ansible_user_id + - name: Debug ansible_facts.user_id ansible.builtin.debug: - var: ansible_user_id + var: ansible_facts.user_id - - name: Debug ansible_user_dir + - name: Debug ansible_facts.user_dir ansible.builtin.debug: - var: ansible_user_dir + var: ansible_facts.user_dir - name: Include php role as root ansible.builtin.include_role: diff --git a/molecule/bookworm_fpm/converge.yml b/molecule/bookworm_fpm/converge.yml index b76bc3f..82d894a 100644 --- a/molecule/bookworm_fpm/converge.yml +++ b/molecule/bookworm_fpm/converge.yml @@ -18,17 +18,17 @@ ansible_python_interpreter: /usr/bin/python3 tasks: - - name: Debug ansible_effective_user_id + - name: Debug ansible_facts.effective_user_id ansible.builtin.debug: - var: ansible_effective_user_id + var: ansible_facts.effective_user_id - - name: Debug ansible_user_id + - name: Debug ansible_facts.user_id ansible.builtin.debug: - var: ansible_user_id + var: ansible_facts.user_id - - name: Debug ansible_user_dir + - name: Debug ansible_facts.user_dir ansible.builtin.debug: - var: ansible_user_dir + var: ansible_facts.user_dir - name: Include php role as root ansible.builtin.include_role: diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index efd3416..34bbb7d 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -18,17 +18,17 @@ ansible_python_interpreter: /usr/bin/python3 tasks: - - name: Debug ansible_effective_user_id + - name: Debug ansible_facts.effective_user_id ansible.builtin.debug: - var: ansible_effective_user_id + var: ansible_facts.effective_user_id - - name: Debug ansible_user_id + - name: Debug ansible_facts.user_id ansible.builtin.debug: - var: ansible_user_id + var: ansible_facts.user_id - - name: Debug ansible_user_dir + - name: Debug ansible_facts.user_dir ansible.builtin.debug: - var: ansible_user_dir + var: ansible_facts.user_dir - name: Include php role as root ansible.builtin.include_role: diff --git a/tasks/apt.yml b/tasks/apt.yml index bf12594..64add5d 100644 --- a/tasks/apt.yml +++ b/tasks/apt.yml @@ -71,7 +71,7 @@ name: php pdiffs: true signed_by: /usr/share/keyrings/deb.sury.org-php.gpg - suites: "{{ ansible_distribution_release }}" + suites: "{{ ansible_facts.distribution_release }}" types: deb uris: https://packages.sury.org/php/ check_mode: true @@ -93,7 +93,7 @@ creates: "/etc/apt/sources.list.d/.php.sources.{{ php_date_timestamp }}.ansible.save" removes: /etc/apt/sources.list.d/php.sources vars: - php_date_timestamp: "{{ ansible_date_time.iso8601_basic_short }}" + php_date_timestamp: "{{ ansible_facts.date_time.iso8601_basic_short }}" when: php_sources_contents_prior != php_sources_check.repo | string | community.general.jc('ini') when: php_sources_path.stat.exists | bool @@ -111,7 +111,7 @@ name: php pdiffs: true signed_by: /usr/share/keyrings/deb.sury.org-php.gpg - suites: "{{ ansible_distribution_release }}" + suites: "{{ ansible_facts.distribution_release }}" types: deb uris: https://packages.sury.org/php/ register: php_sources diff --git a/tasks/check_vars.yml b/tasks/check_vars.yml index 225f8e4..f3b78c9 100644 --- a/tasks/check_vars.yml +++ b/tasks/check_vars.yml @@ -99,10 +99,10 @@ - name: Check that the distro is Debian Bookworm, Bullseye or Buster ansible.builtin.assert: that: - - ansible_distribution_release is defined - - ansible_distribution_release is regex("^bullseye|bookworm|buster$") + - ansible_facts.distribution_release is defined + - ansible_facts.distribution_release is regex("^bullseye|bookworm|buster$") quiet: "{% if ansible_verbosity == 0 %}true{% else %}false{% endif %}" - fail_msg: "The Linux distro {{ ansible_distribution }} {{ ansible_distribution_release }} is not supported by this role" + fail_msg: "The Linux distro {{ ansible_facts.distribution }} {{ ansible_facts.distribution_release }} is not supported by this role" - name: Debug PHP versions and config due to be present and absent ansible.builtin.debug: diff --git a/tasks/file_absent.yml b/tasks/file_absent.yml index e41b0e9..7b10e4d 100644 --- a/tasks/file_absent.yml +++ b/tasks/file_absent.yml @@ -31,7 +31,7 @@ removes: "{{ php_file_absent }}" creates: "{{ php_file_backup }}" vars: - php_file_backup: "{{ php_file_absent | ansible.builtin.dirname }}/.{{ php_file_absent | ansible.builtin.basename }}.{{ ansible_date_time.iso8601_basic_short }}.ansible.save" + php_file_backup: "{{ php_file_absent | ansible.builtin.dirname }}/.{{ php_file_absent | ansible.builtin.basename }}.{{ ansible_facts.date_time.iso8601_basic_short }}.ansible.save" register: php_file_path_absent when: php_file_absent_path.stat.exists | bool diff --git a/tasks/file_edited.yml b/tasks/file_edited.yml index 299f357..4813a7d 100644 --- a/tasks/file_edited.yml +++ b/tasks/file_edited.yml @@ -144,7 +144,7 @@ - name: Set facts for the PHP configuration file ansible.builtin.set_fact: - php_conf_file_backup: "{{ php_conf_file | ansible.builtin.dirname }}/.{{ php_conf_file | ansible.builtin.basename }}.{{ ansible_date_time.iso8601_basic_short }}.bak" + php_conf_file_backup: "{{ php_conf_file | ansible.builtin.dirname }}/.{{ php_conf_file | ansible.builtin.basename }}.{{ ansible_facts.date_time.iso8601_basic_short }}.bak" php_conf_file_changed: false php_conf_file_sapi: null php_conf_file_version: "{{ php_conf_file | ansible.builtin.split(php_file_path_separator) | community.general.json_query('[3]') }}" diff --git a/tasks/file_templated.yml b/tasks/file_templated.yml index a0ac295..98c22da 100644 --- a/tasks/file_templated.yml +++ b/tasks/file_templated.yml @@ -13,7 +13,7 @@ - name: Set facts for the PHP configuration file ansible.builtin.set_fact: - php_conf_file_backup: "{{ php_conf_file | ansible.builtin.dirname }}/.{{ php_conf_file | ansible.builtin.basename }}.{{ ansible_date_time.iso8601_basic_short }}.bak" + php_conf_file_backup: "{{ php_conf_file | ansible.builtin.dirname }}/.{{ php_conf_file | ansible.builtin.basename }}.{{ ansible_facts.date_time.iso8601_basic_short }}.bak" php_conf_file_no_extra_spaces: "{%- if (php_conf_file | ansible.builtin.dirname | ansible.builtin.split('/') | last) == 'mods-available' -%}true{%- else -%}false{%- endif -%}" php_conf_file_proposed_vars: "{{ php_config | community.general.json_query(php_conf_file_proposed_vars_json_query) }}" php_conf_file_sapi: null diff --git a/tasks/pkg.yml b/tasks/pkg.yml index c5e6caf..749062e 100644 --- a/tasks/pkg.yml +++ b/tasks/pkg.yml @@ -164,7 +164,7 @@ - name: Apt clean ansible.builtin.include_tasks: apt_clean.yml when: >- - ( ansible_version.full is version('2.13', '>=') ) and + ( ansible_facts.version.full is version('2.13', '>=') ) and ( ( ( php_packages_installed.changed is defined ) and ( php_packages_installed.changed | bool ) ) or ( ( php_packages_removed_first_run.changed is defined ) and ( php_packages_removed_first_run.changed | bool ) ) or ( ( php_packages_removed_second_run.changed is defined ) and ( php_packages_removed_second_run.changed | bool ) ) ) diff --git a/templates/php.pref.j2 b/templates/php.pref.j2 index e366d86..dd8cbb0 100644 --- a/templates/php.pref.j2 +++ b/templates/php.pref.j2 @@ -1,20 +1,20 @@ # {{ ansible_managed }} -{% if ansible_distribution_release == "bookworm" %} +{% if ansible_facts.distribution_release == "bookworm" %} {% for pkg in php_debian_bookworm_pkg %} Package: {{ pkg }} Pin: origin packages.sury.org Pin-Priority: 500 {% endfor %} -{% elif ansible_distribution_release == "bullseye" %} +{% elif ansible_facts.distribution_release == "bullseye" %} {% for pkg in php_debian_bullseye_pkg %} Package: {{ pkg }} Pin: origin packages.sury.org Pin-Priority: 500 {% endfor %} -{% elif ansible_distribution_release == "buster" %} +{% elif ansible_facts.distribution_release == "buster" %} {% for pkg in php_debian_buster_pkg %} Package: {{ pkg }} Pin: origin packages.sury.org -- GitLab