# Copyright 2019-2024 Chris Croome
#
# This file is part of the Webarchitects PHP Ansible role.
#
# The Webarchitects PHP Ansible role is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
# The Webarchitects PHP Ansible role is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with the Webarchitects PHP Ansible role. If not, see <https://www.gnu.org/licenses/>.
---
- name: Remove config from the section-less PHP configuration file
  block:

    - name: Remove config from the section-less PHP configuration file
      community.general.ini_file:
        path: "{{ php_conf_file }}"
        option: "{{ php_conf_pair.key }}"
        value: "{{ php_conf_pair.value }}"
        state: absent
        mode: "0644"
        owner: root
        group: root
      loop: "{{ php_conf_file_absent_vars | ansible.builtin.dict2items }}"
      loop_control:
        loop_var: php_conf_pair
        label: "{{ php_conf_pair.key }}"
      register: php_conf_file_edited

    - name: Set a fact to indicate that the file has changed  # noqa: no-handler
      ansible.builtin.set_fact:
        php_conf_file_changed: true
      when: php_conf_file_edited.changed | bool

  tags:
    - php
    - php_cfg
    - php_conf
...
