Skip to content
Snippets Groups Projects
checks.yml 7.63 KiB
---
- name: Check that mistakes haven't been made in the variables and arrays
  block:

    - name: Check that at least one module is in apache_mods_enabled and that either mpm_event or mpm_prefork is enabled
      assert:
        that:
          - ( apache_mods_enabled is defined ) and ( apache_mods_enabled[0] is defined )
          - ( "mpm_prefork" in apache_mods_enabled ) or ( "mpm_event" in apache_mods_enabled )

    - name: Checks when mpm_event enabled
      assert:
        that:
          - ( "mpm_prefork" not in apache_mods_enabled )
          - ( "mpm_event" not in apache_mods_disabled )
          - ( "mpm_itk" not in apache_mods_disabled )
      when: ( "mpm_event" in apache_mods_enabled )

    - name: Checks when mpm_prefork enabled
      assert:
        that:
          - ( "mpm_event" not in apache_mods_enabled )
          - ( "mpm_prefork" not in apache_mods_disabled )
      when: ( "mpm_prefork" in apache_mods_enabled )

    - name: Check that there are no duplicates in the mods arrays
      assert:
        that:
          - apache_mods_enabled | unique | count == apache_mods_enabled | count
          - apache_mods_disabled | unique | count == apache_mods_disabled | count

    - name: Check that there are no duplicates in the conf arrays
      assert:
        that:
          - apache_conf_enabled | unique | count == apache_conf_enabled | count
          - apache_conf_disabled | unique | count == apache_conf_disabled | count

    - name: Check that there are no duplicates in the sites arrays
      assert:
        that:
          - apache_sites_enabled | unique | count == apache_sites_enabled | count
          - apache_sites_disabled | unique | count == apache_sites_disabled | count

- name: Check the Apache version, modules and conf, loaded and enabled
  block:

    - name: Check the Apache version
      command: apache2ctl -v
      check_mode: false
      changed_when: false
      register: apache_version_check

    - name: Debug Apache version check
      debug:
        msg: "{{ apache_version_check.stdout_lines[0] }}"
        verbosity: 2

    - name: Set a fact for the Apache version
      set_fact:
        apache_version: "{{ apache_version_check.stdout_lines[0].split(' ')[2] | regex_replace('^Apache[/]') }}"

    - name: Debug Apache version
      debug:
        var: apache_version
        verbosity: 1

    - name: TLS versions
      block:

        - name: Set facts for TLS versions