diff --git a/handlers/main.yml b/handlers/main.yml index e5e4943..e0dce61 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,13 @@ --- +- name: test and restart apache2 + command: apache2ctl configtest + notify: restart apache2 + +- name: test and reload apache2 + command: apache2ctl configtest + notify: reload apache2 + - name: restart apache2 service: name=apache2 state=restarted when: apache2_service_state != 'stopped' diff --git a/tasks/config.yml b/tasks/config.yml index 7d95480..2bb9e5e 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -7,7 +7,7 @@ owner: root group: root mode: "0644" - notify: reload apache2 + notify: test and reload apache2 with_items: - etc/apache2/apache2.conf - etc/apache2/ports.conf diff --git a/tasks/manage_confs.yml b/tasks/manage_confs.yml index 4801699..b636ddd 100644 --- a/tasks/manage_confs.yml +++ b/tasks/manage_confs.yml @@ -7,7 +7,7 @@ creates: "/etc/apache2/conf-enabled/{{ item.id }}.conf" when: item.state is not defined or item.state != 'absent' with_items: "{{ apache2_confs }}" - notify: reload apache2 + notify: test and reload apache2 - name: Disabling conf command: > @@ -16,4 +16,4 @@ removes: "/etc/apache2/conf-enabled/{{ item.id }}.conf" when: item.state is defined and item.state == 'absent' with_items: "{{ apache2_confs }}" - notify: reload apache2 + notify: test and reload apache2 diff --git a/tasks/manage_default.yml b/tasks/manage_default.yml index ac8f333..28e914b 100644 --- a/tasks/manage_default.yml +++ b/tasks/manage_default.yml @@ -4,7 +4,7 @@ file: dest: /etc/apache2/sites-enabled/000-default.conf state: absent - notify: reload apache2 + notify: test and reload apache2 when: apache2_remove_default - name: Removing default host diff --git a/tasks/manage_modules.yml b/tasks/manage_modules.yml index 2a9a03a..7e02406 100644 --- a/tasks/manage_modules.yml +++ b/tasks/manage_modules.yml @@ -7,7 +7,7 @@ creates: "/etc/apache2/mods-enabled/{{ item.id }}.load" when: item.state is not defined or item.state != 'absent' with_items: "{{ apache2_modules }}" - notify: reload apache2 + notify: test and reload apache2 - name: Disabling modules command: > @@ -16,4 +16,4 @@ removes: "/etc/apache2/mods-enabled/{{ item.id }}.load" when: item.state is defined and item.state == 'absent' with_items: "{{ apache2_modules }}" - notify: reload apache2 + notify: test and reload apache2 diff --git a/tasks/manage_sites.yml b/tasks/manage_sites.yml index 0bc039a..20e45a7 100644 --- a/tasks/manage_sites.yml +++ b/tasks/manage_sites.yml @@ -3,6 +3,7 @@ - name: Creating webroots file: dest: "{{ apache2_sites_basedir }}/{{ item.id }}/htdocs" + mode: "0755" state: directory when: item.add_webroot is defined and item.add_webroot with_items: "{{ apache2_sites }}" @@ -15,7 +16,7 @@ group: root mode: "0644" with_items: "{{ apache2_sites }}" - notify: reload apache2 + notify: test and reload apache2 - name: Enabling sites file: @@ -24,7 +25,7 @@ state: link when: item.state is not defined or item.state == 'present' with_items: "{{ apache2_sites }}" - notify: reload apache2 + notify: test and reload apache2 - name: Disabling sites file: @@ -32,4 +33,4 @@ state: absent when: item.state is defined and item.state == 'absent' with_items: "{{ apache2_sites }}" - notify: reload apache2 + notify: test and reload apache2