diff --git a/defaults/main.yml b/defaults/main.yml index 95488aec80e91c666ed9367727c1cc55f7d338f5..0f3a0f177dd77b9dea9150db632510f3be557210 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,15 +5,6 @@ php_phpquery: /usr/sbin/phpquery php_versions: '8.1': state: present - sapis: - apache2: - state: absent - cli: - state: present - fpm: - state: present - phpdbg: - state: absent packages_absent: - libapache2-mod-php8.1 - php8.1-phpdbg @@ -34,8 +25,6 @@ php_versions: - php8.1-uploadprogress - php8.1-xml - php8.1-xsl - '8.0': - state: present sapis: apache2: state: absent @@ -45,6 +34,8 @@ php_versions: state: present phpdbg: state: absent + '8.0': + state: present packages_absent: - libapache2-mod-php8.0 - php8.0-phpdbg @@ -65,8 +56,6 @@ php_versions: - php8.0-uploadprogress - php8.0-xml - php8.0-xsl - '7.4': - state: present sapis: apache2: state: absent @@ -76,6 +65,8 @@ php_versions: state: present phpdbg: state: absent + '7.4': + state: present packages_absent: - libapache2-mod-php7.4 - php7.4-phpdbg @@ -99,6 +90,15 @@ php_versions: - php7.4-uploadprogress - php7.4-xml - php7.4-xsl + sapis: + apache2: + state: absent + cli: + state: present + fpm: + state: present + phpdbg: + state: absent '7.3': state: absent '7.2': diff --git a/tasks/checks.yml b/tasks/checks.yml index 9751b51e42b943c5614fe421d52b4750c342fa7d..8f19521ca97dc2429f078732935014ee7e97ea62 100644 --- a/tasks/checks.yml +++ b/tasks/checks.yml @@ -51,6 +51,14 @@ var: php_versions_proposed verbosity: 2 + - name: Check that for each proposed version of PHP there are not packages due to be absent and present at the same time + include_tasks: pkg_checks.yml + loop: "{{ php_versions_proposed }}" + loop_control: + loop_var: version + label: "{{ version }}" + when: ( php_versions_proposed is defined ) and ( php_versions_proposed != [] ) + - name: Generate an array of PHP versions to remove set_fact: php_versions_remove: "{{ php_versions_existing | difference(php_versions_proposed) }}" @@ -83,7 +91,7 @@ var: php_versions_absent verbosity: 2 - - name: Include SAPI checks for PHP versions due to be absentd + - name: Include SAPI checks for PHP versions due to be absent include_tasks: sapi_checks.yml loop: "{{ php_versions_absent }}" loop_control: diff --git a/tasks/local_facts.yml b/tasks/local_facts.yml index 5ea60e8579d8978839b850d6891cac2d75bff578..618600a7faab68e6e8c167015da3f994d4589ffe 100644 --- a/tasks/local_facts.yml +++ b/tasks/local_facts.yml @@ -42,12 +42,12 @@ - name: Print Ansible dpkg --architecture variables debug: - msg: "{{ ansible_facts['ansible_local']['dpkg_arch'] }}" + msg: "{{ ansible_local.dpkg_arch }}" verbosity: 2 - name: Print Ansible phpquery dictionary debug: - msg: "{{ ansible_facts['ansible_local']['phpquery'] }}" + msg: "{{ ansible_local.phpquery }}" verbosity: 2 tags: diff --git a/tasks/pkg_checks.yml b/tasks/pkg_checks.yml new file mode 100644 index 0000000000000000000000000000000000000000..dc2c3e9ae81a2f2f61abb659ccf11e4ce326bbe7 --- /dev/null +++ b/tasks/pkg_checks.yml @@ -0,0 +1,33 @@ +--- +- name: PHP versions package checks + block: + + - name: "Check that a package is not set to be present and absent at the same time for PHP {{ version }}" + assert: + that: + - pkg not in php_versions[version].packages_absent + fail_msg: "Package {{ pkg }} is set to be both present and absent at the same time for PHP {{ version }}" + loop: "{{ php_versions[version].packages_present }}" + loop_control: + loop_var: pkg + label: "{{ pkg }}" + when: + - ( php_versions[version].packages_absent is defined ) and ( php_versions[version].packages_absent != [] ) + - ( php_versions[version].packages_present is defined ) and ( php_versions[version].packages_present != [] ) + + - name: "Check that a package is not set to be absent and present at the same time for PHP {{ version }}" + assert: + that: + - pkg not in php_versions[version].packages_present + fail_msg: "Package {{ pkg }} is set to be both absent and present at the same time for PHP {{ version }}" + loop: "{{ php_versions[version].packages_absent }}" + loop_control: + loop_var: pkg + label: "{{ pkg }}" + when: + - ( php_versions[version].packages_absent is defined ) and ( php_versions[version].packages_absent != [] ) + - ( php_versions[version].packages_present is defined ) and ( php_versions[version].packages_present != [] ) + + tags: + - php +... diff --git a/tasks/sapi_checks.yml b/tasks/sapi_checks.yml index 85b948a3a4114daf50eb87e9d86fc52244dc2a51..61f634600e191fa4e38d54d896b1e89c4126f746 100644 --- a/tasks/sapi_checks.yml +++ b/tasks/sapi_checks.yml @@ -2,14 +2,25 @@ - name: PHP SAPI checks block: - - name: "Include PHP {{ version }} SAPI state checks" - include_tasks: sapi_state_checks.yml + - name: "Check that SAPI is not set to be present when PHP {{ version }} is set to be removed" + assert: + that: + - sapi.value.state == "absent" + fail_msg: "SAPI {{ sapi.key }} is not set to be absent for PHP {{ version }}, yet PHP {{ version }} is set to be removed." loop: "{{ php_versions[version].sapis | dict2items }}" loop_control: loop_var: sapi label: "{{ sapi.key }}" - when: - - php_versions[version].sapis is defined + when: php_versions[version].sapis is defined + +# - name: "Include PHP {{ version }} SAPI state checks" +# include_tasks: sapi_state_checks.yml +# loop: "{{ php_versions[version].sapis | dict2items }}" +# loop_control: +# loop_var: sapi +# label: "{{ sapi.key }}" +# when: +# - php_versions[version].sapis is defined # - php_versions[version].sapis.sapi is defined # - php_versions[version].sapis.sapi.state is defined