# 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: Verify PHP variables
  block:

    - name: Debug the hostvars variable names that start with php_
      ansible.builtin.debug:
        var: phpvarnames
        verbosity: "{% if ansible_check_mode | bool %}3{% else %}4{% endif %}"

    - name: Debug the hostvars variable names that start with php_
      ansible.builtin.debug:
        var: phphostvars
        verbosity: "{% if ansible_check_mode | bool %}3{% else %}4{% endif %}"

    - name: Check php_ variables using meta/argument_specs.yml
      ansible.builtin.validate_argument_spec:
        argument_spec: "{{ (lookup('ansible.builtin.file', 'meta/argument_specs.yml') | from_yaml)['argument_specs']['main']['options'] }}"
        provided_arguments: "{{ phphostvars }}"

  when:
    - php_verify is defined
    - php_verify | bool
  tags:
    - php
    - php_verify
...
