diff --git a/tasks/a2conf.yml b/tasks/a2conf.yml index 506f82c731760b4dd3de3b0ba59b6b26d2868f89..d5a10528c9c1cc38a2a041017fd161d6db8b9df2 100644 --- a/tasks/a2conf.yml +++ b/tasks/a2conf.yml @@ -23,6 +23,7 @@ loop_control: loop_var: apache_conf label: "{{ apache_conf }}" + notify: Restart Apache - name: Check that all the conf to be enabled exist ansible.builtin.stat: @@ -49,6 +50,7 @@ loop_control: loop_var: apache_conf label: "{{ apache_conf }}" + notify: Restart Apache tags: - apache diff --git a/tasks/a2mod.yml b/tasks/a2mod.yml index fd0a565625c01c1ed06e4f7766b0e2883c4fa926..032f9daba11eb513a2cdcb07d78cd1acc13a2af7 100644 --- a/tasks/a2mod.yml +++ b/tasks/a2mod.yml @@ -20,6 +20,7 @@ when: - ( "fcgid" in apache_mods_disabled ) - ( "libapache2-mod-fcgid" in ansible_local.dpkg.installed ) + notify: Restart Apache - name: Apache suEXEC package absent ansible.builtin.apt: @@ -30,6 +31,7 @@ when: - ( "suexec" in apache_mods_disabled ) - ( "apache2-suexec-pristine" in ansible_local.dpkg.installed ) + notify: Restart Apache - name: "Apache package absent {{ apache_phpfpm_mod }}" ansible.builtin.apt: @@ -43,6 +45,7 @@ - apache_php | bool - ( "apache_phpfpm_mod" in apache_mods_disabled ) - ( apache_mod_php_pkg in ansible_local.dpkg.installed ) + notify: Restart Apache - name: Disable modules community.general.apache2_module: @@ -53,6 +56,7 @@ loop_control: loop_var: apache_mod label: "{{ apache_mod }}" + notify: Restart Apache - name: Re-read Ansible local facts ansible.builtin.setup: @@ -77,6 +81,7 @@ when: - ( "suexec" in apache_mods_enabled ) - ( "apache2-suexec-pristine" not in ansible_local.dpkg.installed ) + notify: Restart Apache - name: Apache FastCGI package present ansible.builtin.apt: @@ -87,6 +92,7 @@ when: - ( "fcgid" in apache_mods_enabled ) - ( "libapache2-mod-fcgid" not in ansible_local.dpkg.installed ) + notify: Restart Apache - name: Apache mod_php package present ansible.builtin.apt: @@ -100,19 +106,20 @@ - apache_php | bool - ( "apache_phpfpm_mod" in apache_mods_enabled ) - ( apache_mod_php_pkg not in ansible_local.dpkg.installed ) + notify: Restart Apache - - name: Check that all the modules to be enabled exist - ansible.builtin.stat: - path: "/etc/apache2/mods-available/{{ apache_mod }}.load" - when: apache_mod not in ansible_local.a2query.modules_enabled - register: apache_mod_path - failed_when: - - not ansible_check_mode | bool - - not apache_mod_path.stat.exists | bool - loop: "{{ apache_mods_enabled }}" - loop_control: - loop_var: apache_mod - label: "{{ apache_mod }}" + # - name: Check that all the modules to be enabled exist + # ansible.builtin.stat: + # path: "/etc/apache2/mods-available/{{ apache_mod }}.load" + # when: apache_mod not in ansible_local.a2query.modules_enabled + # register: apache_mod_path + # failed_when: + # - not ansible_check_mode | bool + # - not apache_mod_path.stat.exists | bool + # loop: "{{ apache_mods_enabled }}" + # loop_control: + # loop_var: apache_mod + # label: "{{ apache_mod }}" - name: Apache modules enabled community.general.apache2_module: @@ -123,6 +130,7 @@ loop_control: loop_var: apache_mod label: "{{ apache_mod }}" + notify: Restart Apache - name: Re-read Ansible local facts ansible.builtin.setup: diff --git a/tasks/a2site.yml b/tasks/a2site.yml index c894a7c6dd89ab84a62ecf4a6795655fd098d954..69717715b40b27917cc09789e04a05ce66606885 100644 --- a/tasks/a2site.yml +++ b/tasks/a2site.yml @@ -23,19 +23,20 @@ loop_control: loop_var: apache_site label: "{{ apache_site }}" + notify: Restart Apache - - name: Check that all the sites to be enabled exist - ansible.builtin.stat: - path: "/etc/apache2/sites-available/{{ apache_site }}.conf" - when: apache_site not in ansible_local.a2query.sites_enabled - register: apache_site_path - failed_when: - - not ansible_check_mode | bool - - not apache_site_path.stat.exists | bool - loop: "{{ apache_sites_enabled }}" - loop_control: - loop_var: apache_site - label: "{{ apache_site }}" + # - name: Check that all the sites to be enabled exist + # ansible.builtin.stat: + # path: "/etc/apache2/sites-available/{{ apache_site }}.conf" + # when: apache_site not in ansible_local.a2query.sites_enabled + # register: apache_site_path + # failed_when: + # - not ansible_check_mode | bool + # - not apache_site_path.stat.exists | bool + # loop: "{{ apache_sites_enabled }}" + # loop_control: + # loop_var: apache_site + # label: "{{ apache_site }}" - name: Apache sites enabled ansible.builtin.command: "a2ensite {{ apache_site }}" @@ -49,6 +50,7 @@ loop_control: loop_var: apache_site label: "{{ apache_site }}" + notify: Restart Apache tags: - apache diff --git a/tasks/cloudflare.yml b/tasks/cloudflare.yml index 98504a20b73fd5d26227632b7aa81dfe6d1e78ea..586a290a03cd174798c0d1317cd0cfb8ce522b72 100644 --- a/tasks/cloudflare.yml +++ b/tasks/cloudflare.yml @@ -41,6 +41,7 @@ owner: root group: root mode: "0644" + notify: Restart Apache tags: - apache diff --git a/tasks/config.yml b/tasks/config.yml index 4adfa8c04d04fd6a581ef8ec90eb8da79cafefe3..c6a0625a04b97e693c7aa7001f2f3bd70c006c8a 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -38,6 +38,7 @@ loop_control: loop_var: file label: "{{ file }}" + notify: Restart Apache - name: Custom Apache mods available in place ansible.builtin.template: @@ -77,6 +78,7 @@ group: root mode: "0644" when: ( apache_sites_enabled is defined ) and ( "000-default" in apache_sites_enabled ) + notify: Restart Apache - name: Conditional update default-ssl.conf ansible.builtin.template: @@ -86,6 +88,7 @@ group: root mode: "0644" when: ( apache_sites_enabled is defined ) and ( "default-ssl" in apache_sites_enabled ) + notify: Restart Apache - name: Apache localhost site available ansible.builtin.template: @@ -94,6 +97,7 @@ owner: root group: root mode: "0644" + notify: Restart Apache - name: Conditionally include Webarchitects config ansible.builtin.include_tasks: webarch.yml @@ -124,6 +128,7 @@ owner: root group: root mode: "0644" + notify: Restart Apache - name: Expires and robots conf available ansible.builtin.template: @@ -141,6 +146,7 @@ loop_control: loop_var: file label: "{{ file }}" + notify: Restart Apache - name: Apache mpm_prefork.conf in place ansible.builtin.template: @@ -150,6 +156,7 @@ group: root mode: "0644" when: ( "mpm_prefork" in apache_mods_enabled ) + notify: Restart Apache - name: Apache ratelimit conf present ansible.builtin.template: @@ -159,10 +166,12 @@ group: root mode: "0644" when: '"ratelimit" in apache_mods_enabled' + notify: Restart Apache - name: Cloudflare config available ansible.builtin.include_tasks: cloudflare.yml when: ( "remoteip" in apache_mods_enabled ) + notify: Restart Apache - name: Conditionally provision a Let's Encrypt cert using acmesh role block: diff --git a/tasks/main.yml b/tasks/main.yml index ea65d7541d20abca3411c94c566266c9441ce04e..8892ec0ddec2195072e1d5690c9e0a4dd79f2286 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -46,6 +46,7 @@ - apache_pkgs_absent != [] - ansible_local.dpkg.installed is defined - apache_pkgs_absent | ansible.builtin.intersect(ansible_local.dpkg.installed) != [] + notify: Restart Apache - name: Apache present from buster-backports ansible.builtin.apt: @@ -59,6 +60,7 @@ - apache_pkgs_present is defined - ( "apache2" in apache_pkgs_present ) - ansible_distribution_release == "buster" + notify: Restart Apache - name: Apache packages present ansible.builtin.apt: @@ -71,6 +73,7 @@ - apache_pkgs_present != [] - ansible_local.dpkg.installed is defined - apache_pkgs_present | ansible.builtin.difference(ansible_local.dpkg.installed) != [] + notify: Restart Apache when: >- ( ( apache_pkgs_absent is defined ) and ( apache_pkgs_absent != [] ) ) or @@ -99,6 +102,7 @@ community.crypto.openssl_dhparam: path: "{{ apache_dhparam_path }}" size: "{{ apache_dhparam_size }}" + notify: Restart Apache - name: Include suEXEC tasks ansible.builtin.include_tasks: suexec.yml @@ -123,6 +127,7 @@ mode: "0755" owner: root group: root + notify: Restart Apache - name: Include Apache check config tasks ansible.builtin.include_tasks: check_config.yml @@ -144,6 +149,7 @@ name: apache2 enabled: true when: ansible_distribution_release != "stretch" + notify: Restart Apache - name: Apache configtest ansible.builtin.command: apache2ctl configtest @@ -162,14 +168,6 @@ msg: "{{ apache_configtest.stdout_lines }}" when: ( "Syntax OK" not in apache_configtest.stderr ) or ( apache_configtest.rc == 1 ) - - name: Apache restarted - ansible.builtin.service: - name: apache2 - state: restarted - when: ( "Syntax OK" in apache_configtest.stderr ) or ( apache_configtest.rc == 0 ) - tags: - - molecule-idempotence-notest - when: apache | bool tags: - apache diff --git a/tasks/mc3.yml b/tasks/mc3.yml index b73a937237f599fa3f550c5d49a3f0c44923c056..f3bbe1af9e304b903459b99a2c0588ac39f617a3 100644 --- a/tasks/mc3.yml +++ b/tasks/mc3.yml @@ -32,6 +32,7 @@ owner: root group: root mode: "0644" + notify: Restart Apache tags: - apache diff --git a/tasks/md.yml b/tasks/md.yml index 9153493c570cc13e4b608de5db0da07d5193ef45..1f94dd61513dddeee696d36952e4702b1262774d 100644 --- a/tasks/md.yml +++ b/tasks/md.yml @@ -19,6 +19,7 @@ - libcurl4-openssl-dev - libjansson-dev state: present + notify: Restart Apache - name: Find the latest version of mod_md block: @@ -66,6 +67,7 @@ community.general.make: chdir: /usr/local/src/mod_md target: install + notify: Restart Apache when: apache_md_repo.changed diff --git a/tasks/suexec.yml b/tasks/suexec.yml index 0f8c23c869694718d137c80080e88a72c0886c19..fa5b197447d501aa1856b658c1cb5a8e0aa48d86 100644 --- a/tasks/suexec.yml +++ b/tasks/suexec.yml @@ -16,6 +16,7 @@ pkg: - apache2-suexec-custom state: present + notify: Restart Apache - name: Apache suEXEC config directory only readable by root ansible.builtin.file: diff --git a/tasks/webarch.yml b/tasks/webarch.yml index a60e578f4ac8c064d044aaad60221d3a2428875b..acfa067a0f48e8e6b5c388f9fce86c581feede8a 100644 --- a/tasks/webarch.yml +++ b/tasks/webarch.yml @@ -40,6 +40,7 @@ mode: "0644" owner: root group: root + notify: Restart Apache tags: - apache