diff --git a/README.md b/README.md index 08fd3aa222f9eca813eb2ade7073705eca8949c8..1a740fa64651a9b0ca211125759deed24c4a3065 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,15 @@ This role isn't setup to generate multiple `pool.d` config files, but the [users <!-- END_ANSIBLE_DOCS --> +## Help + +Reinstall a package and the configuration files when they have been deleted (see [serverfault comment](https://serverfault.com/a/670776)): + +```bash +UCF_FORCE_CONFFMISS=1 apt-get -o Dpkg::Options::="–force-confmiss" install "php8.1-fpm" +``` + + ## Repo History In June 2021 this role was renamed from `phpfpm` to `php` and the URL of the git repo and all the variable names and tags have been updated to match. diff --git a/defaults/main.yml b/defaults/main.yml index 5c8ad2751d3aaf5df8ac0c4840f7de2583ecc038..99f30018d21d32329fccd9ba967dacd308d31929 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,12 +13,12 @@ php: true # cat /etc/php/8.1/fpm/php.ini | jc --ini -yp php_check_legacy_variables: true php_config: - - name: PHP 8.2 configuration - version: "8.2" - state: absent + # - name: PHP 8.2 configuration + # version: "8.2" + # state: absent - name: PHP 8.1 configuration version: "8.1" - state: absent + state: present files: - path: /etc/php/8.1/apache2/php.ini state: absent @@ -81,41 +81,41 @@ php_config: state: present php_sury: true php_versions: - - name: PHP 8.2 packages - version: "8.2" - state: absent - pkg_absent: - - libapache2-mod-php8.2 - - php8.2-phpdbg - pkg_present: - - php8.2-apcu - - php8.2-bcmath - - php8.2-bz2 - - php8.2-cli - - php8.2-common - - php8.2-curl - - php8.2-gd - - php8.2-gmp - - php8.2-fpm - - php8.2-imagick - - php8.2-imap - - php8.2-intl - - php8.2-ldap - - php8.2-mbstring - - php8.2-mysql - - php8.2-opcache - - php8.2-readline - - php8.2-sqlite3 - - php8.2-soap - - php8.2-uploadprogress - - php8.2-xml - - php8.2-xmlrpc - - php8.2-xsl - - php8.2-zip - - php-pear + # - name: PHP 8.2 packages + # version: "8.2" + # state: absent + # pkg_absent: + # - libapache2-mod-php8.2 + # - php8.2-phpdbg + # pkg_present: + # - php8.2-apcu + # - php8.2-bcmath + # - php8.2-bz2 + # - php8.2-cli + # - php8.2-common + # - php8.2-curl + # - php8.2-gd + # - php8.2-gmp + # - php8.2-fpm + # - php8.2-imagick + # - php8.2-imap + # - php8.2-intl + # - php8.2-ldap + # - php8.2-mbstring + # - php8.2-mysql + # - php8.2-opcache + # - php8.2-readline + # - php8.2-sqlite3 + # - php8.2-soap + # - php8.2-uploadprogress + # - php8.2-xml + # - php8.2-xmlrpc + # - php8.2-xsl + # - php8.2-zip + # - php-pear - name: PHP 8.1 packages version: "8.1" - state: absent + state: present pkg_absent: - libapache2-mod-php8.1 - php8.1-phpdbg diff --git a/tasks/file_templated.yml b/tasks/file_templated.yml index 651a56ba296e68be6f9d790d0386ad1a0e4e8859..f9c4d475462df882fd069464c12e263a941b9ef3 100644 --- a/tasks/file_templated.yml +++ b/tasks/file_templated.yml @@ -113,7 +113,9 @@ state: reloaded when: + - php_conf_file_version is defined - php_conf_file_version in php_ver_installed + - php_conf_file_templated.changed is defined - php_conf_file_templated.changed | bool - php_conf_file_sapi is defined - php_conf_file_sapi == "fpm" @@ -123,7 +125,9 @@ path: "{{ php_conf_file_backup }}" state: absent changed_when: false - when: not php_conf_file_templated.changed | bool + when: + - php_conf_file_templated.changed is defined + - not php_conf_file_templated.changed | bool tags: - php diff --git a/tasks/pkg.yml b/tasks/pkg.yml index cfdb22aac116aa0393b4bcdc47ad3311b2001168..e592ac2fad756695c306a4bc07ba2022c4947aac 100644 --- a/tasks/pkg.yml +++ b/tasks/pkg.yml @@ -71,10 +71,10 @@ var: php_pkg_install verbosity: "{% if ansible_check_mode | bool and php_pkg_install != [] %}0{% elif php_pkg_install != [] %}1{% else %}2{% endif %}" - - name: PHP packages purged + - name: PHP packages absent ansible.builtin.apt: pkg: "{{ php_pkg_rm }}" - purge: true + purge: false state: absent register: php_packages_removed when: php_pkg_rm != [] @@ -83,7 +83,10 @@ ansible.builtin.apt: pkg: "{{ php_pkg_install }}" state: latest + dpkg_options: force-confmiss update_cache: true + environment: + UCF_FORCE_CONFFMISS: "1" register: php_packages_installed when: php_pkg_install != [] diff --git a/templates/php.j2 b/templates/php.j2 index 97836bfa75ae90aec0fd65b40b2950ec9716e506..f5e1df00f1d4e7b532070a7cb2e9850b77461edd 100644 --- a/templates/php.j2 +++ b/templates/php.j2 @@ -1,11 +1,9 @@ -# {{ systemd_ansible_managed }} - -{% for php_section in | dict2items %} +# {{ ansible_managed }} +{% for php_section in php_conf_file_proposed_vars | dict2items %} [{{ php_section.key }}] {% for php_variable_pair in php_section.value | dict2items %} {{ php_variable_pair.key }} = {{ php_variable_pair.value }} - {% endfor %} {% endfor %}