diff --git a/boost-proxy/tasks/main.yml b/boost-proxy/tasks/main.yml index 9587705e..a0dd1afe 100644 --- a/boost-proxy/tasks/main.yml +++ b/boost-proxy/tasks/main.yml @@ -23,7 +23,7 @@ # Sites configuration ###################### -- include_tasks: sites.yml +- import_tasks: sites.yml ################# # external roles @@ -45,4 +45,4 @@ # validations ############## -- include_tasks: validate.yml +- include: validate.yml diff --git a/boost-proxy/tasks/site.yml b/boost-proxy/tasks/site.yml new file mode 100644 index 00000000..7f4cc870 --- /dev/null +++ b/boost-proxy/tasks/site.yml @@ -0,0 +1,33 @@ +--- + +# HAProxy + +- name: "Copy custom error pages for {{ site }}" + template: + src: "{{ template }}" + dest: "/etc/haproxy/sites/{{ site }}/" + owner: root + group: root + mode: "0644" + loop: "{{ query('fileglob', 'templates/boost-sites/{{ site }}/haproxy/*.http') }}" + loop_control: + loop_var: template + tags: + - haproxy + - config + - update-config + +# Varnish + +- name: "Copy sites custom VCL config for {{ site }}" + template: + src: "templates/boost-sites/{{ site }}/varnish/default.vcl.j2" + dest: "/etc/varnish/sites/{{ site }}.vcl" + owner: root + group: root + mode: "0644" + notify: reload varnish + tags: + - varnish + - config + - update-config diff --git a/boost-proxy/tasks/sites.yml b/boost-proxy/tasks/sites.yml index 4968fa76..b725a8dd 100644 --- a/boost-proxy/tasks/sites.yml +++ b/boost-proxy/tasks/sites.yml @@ -14,171 +14,6 @@ - config - update-config -- name: Create sites directories - file: - dest: "/etc/haproxy/sites/{{ item }}" - owner: root - group: root - mode: "0755" - state: directory - loop: "{{ boost_sites_enabled }}" - tags: - - haproxy - - config - - update-config - -- name: Copy maintenance page - template: - src: "{{ lookup('first_found', file) }}" - dest: "/etc/haproxy/sites/{{ site }}/maintenance.http" - owner: root - group: root - mode: "0644" - vars: - file: - - "templates/boost-sites/{{ site }}/haproxy/maintenance.http" - - "templates/haproxy/maintenance.http" - loop: "{{ boost_sites_enabled }}" - loop_control: - loop_var: site - tags: - - haproxy - - config - - update-config - -- name: Copy 504 page - template: - src: "{{ lookup('first_found', file, errors='ignore') }}" - dest: "/etc/haproxy/sites/{{ site }}/504.http" - owner: root - group: root - mode: "0644" - vars: - file: - - "templates/boost-sites/{{ site }}/haproxy/504.http" - - "templates/haproxy/504.http" - loop: "{{ boost_sites_enabled }}" - loop_control: - loop_var: site - tags: - - haproxy - - config - - update-config - -- name: Copy 503 page - template: - src: "{{ lookup('first_found', file, errors='ignore') }}" - dest: "/etc/haproxy/sites/{{ site }}/503.http" - owner: root - group: root - mode: "0644" - vars: - file: - - "templates/boost-sites/{{ site }}/haproxy/503.http" - - "templates/haproxy/503.http" - loop: "{{ boost_sites_enabled }}" - loop_control: - loop_var: site - tags: - - haproxy - - config - - update-config - -- name: Copy 502 page - template: - src: "{{ lookup('first_found', file, errors='ignore') }}" - dest: "/etc/haproxy/sites/{{ site }}/502.http" - owner: root - group: root - mode: "0644" - vars: - file: - - "templates/boost-sites/{{ site }}/haproxy/502.http" - - "templates/haproxy/502.http" - loop: "{{ boost_sites_enabled }}" - loop_control: - loop_var: site - tags: - - haproxy - - config - - update-config - -- name: Copy 500 page - template: - src: "{{ lookup('first_found', file) }}" - dest: "/etc/haproxy/sites/{{ site }}/500.http" - owner: root - group: root - mode: "0644" - vars: - file: - - "templates/boost-sites/{{ site }}/haproxy/500.http" - - "templates/haproxy/500.http" - loop: "{{ boost_sites_enabled }}" - loop_control: - loop_var: site - tags: - - haproxy - - config - - update-config - -- name: Copy 400 page - template: - src: "{{ lookup('first_found', file) }}" - dest: "/etc/haproxy/sites/{{ site }}/400.http" - owner: root - group: root - mode: "0644" - vars: - file: - - "templates/boost-sites/{{ site }}/haproxy/400.http" - - "templates/haproxy/400.http" - loop: "{{ boost_sites_enabled }}" - loop_control: - loop_var: site - tags: - - haproxy - - config - - update-config - -- name: Copy 403 page - template: - src: "{{ lookup('first_found', file) }}" - dest: "/etc/haproxy/sites/{{ site }}/403.http" - owner: root - group: root - mode: "0644" - vars: - file: - - "templates/boost-sites/{{ site }}/haproxy/403.http" - - "templates/haproxy/403.http" - loop: "{{ boost_sites_enabled }}" - loop_control: - loop_var: site - tags: - - haproxy - - config - - update-config - -- name: Copy 404 page - template: - src: "{{ lookup('first_found', file) }}" - dest: "/etc/haproxy/sites/{{ site }}/404.http" - owner: root - group: root - mode: "0644" - vars: - file: - - "templates/boost-sites/{{ site }}/haproxy/404.http" - - "templates/haproxy/404.http" - loop: "{{ boost_sites_enabled }}" - loop_control: - loop_var: site - tags: - - haproxy - - config - - update-config - # Varnish - name: Create sites parent directory @@ -193,18 +28,16 @@ - config - update-config -- name: Copy sites custom VCL - template: - src: "templates/boost-sites/{{ site }}/varnish/default.vcl.j2" - dest: "/etc/varnish/sites/{{ site }}.vcl" - owner: root - group: root - mode: "0644" +# Each site + +- name: Create site configuration + include: site.yml loop: "{{ boost_sites_enabled }}" loop_control: loop_var: site - notify: reload varnish + when: + - boost_sites_enabled | length > 0 tags: - - varnish + - haproxy - config - update-config