Skip to content
Snippets Groups Projects
main.yml 5.27 KiB
# Copyright 2019-2023 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: PHP
  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 }}"

    - name: Include apt role local fact tasks
      ansible.builtin.include_role:
        name: apt
        tasks_from: local_facts.yml
      when: >-
        ( ansible_local.dpkg.arch is not defined ) or
        ( ansible_local.gpg.version is not defined ) or
        ( ansible_local.bash.path is not defined )
      tags:
        - php_apt

    - name: Include PHP variable check tasks
      ansible.builtin.include_tasks: check_vars.yml
      tags:
        - php_cfg
        - php_conf

    - name: Include the init system check tasks
      ansible.builtin.include_tasks: check_init.yml
      tags:
        - php_apt
        - php_cfg
        - php_conf
        - php_mods
        - php_pkg

    - name: Include Sury PHP apt repo tasks
      ansible.builtin.include_tasks: apt.yml
      when: php_sury is defined
      tags:
        - php_apt

    - name: Debug PHP versions that are to be installed
      ansible.builtin.debug:
        var: php_ver_present
        verbosity: "{% if ansible_check_mode | bool %}1{% else %}2{% endif %}"
      tags:
        - php_pkg

    - name: Include PHP package tasks
      ansible.builtin.include_tasks: pkg.yml
      when: php_versions is defined