Newer
Older
# Copyright 2018-2023 Chris Croome
#
# This file is part of the Webarchitects Apache Ansible role.
#
# The Webarchitects Apache 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 Apache 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 Apache Ansible role. If not, see <https://www.gnu.org/licenses/>.
- name: Apache role skipped
ansible.builtin.debug:
msg: "The tasks in the Apache role are not being run since the apache variable is not true."
when: not apache | bool
tags:
- apache
- name: Verify variables that start with apache_
ansible.builtin.include_tasks: verify.yml
when:
- apache_verify is defined
- apache_verify | bool
- 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 )
- name: Packages present and absent
block:
- name: Apache packages absent
ansible.builtin.apt:
- apache_pkgs_absent is defined
- apache_pkgs_absent != []
- apache_pkgs_absent | ansible.builtin.intersect(ansible_local.dpkg.installed) != []
- name: Apache present from buster-backports
ansible.builtin.apt:
pkg:
- apache2
state: latest
install_recommends: true
default_release: buster-backports
update_cache: true
- ( "apache2" in apache_pkgs_present )
- ansible_distribution_release == "buster"
- name: Apache packages present
ansible.builtin.apt:
state: present
install_recommends: true
- apache_pkgs_present is defined
- apache_pkgs_present != []
- apache_pkgs_present | ansible.builtin.difference(ansible_local.dpkg.installed) != []
( ( apache_pkgs_absent is defined ) and ( apache_pkgs_absent != [] ) ) or
( ( apache_pkgs_present is defined ) and ( apache_pkgs_present != [] ) )
when: ansible_local.a2query is not defined
path: "{{ apache_document_root }}"
state: directory
- name: Include MPM switching tasks
ansible.builtin.include_tasks: mpm.yml
when: ansible_local.a2query.mpm not in apache_mods_enabled
path: "{{ apache_dhparam_path }}"
size: "{{ apache_dhparam_size }}"
when:
- apache_suexec is defined
- apache_suexec | bool
when:
- ( "md" in apache_mods_enabled )
- apache_md_version is defined
- apache_md_version != "default"
- name: Include Apache check config tasks
ansible.builtin.include_tasks: check_config.yml
when: ( apache_mods_disabled is defined ) or ( apache_mods_enabled is defined )
- name: Apache conf disabled and enabled
when: ( apache_sites_disabled is defined ) or ( apache_conf_enabled is defined )
- name: Apache sites disabled and enabled
when: ( apache_sites_disabled is defined ) or ( apache_sites_enabled is defined )
- name: Apache enabled for systemd servers
check_mode: false
changed_when: false
- name: Print the apache2ctl configtest standard error
msg: "{{ apache_configtest.stderr }}"
verbosity: 1
- name: Fail if Apache configtest is not OK
msg: "{{ apache_configtest.stdout_lines }}"
when: ( "Syntax OK" not in apache_configtest.stderr ) or ( apache_configtest.rc == 1 )