ansible-roles/boost-proxy/tasks/sites.yml

211 lines
4.4 KiB
YAML

---
# HAProxy
- name: Create sites parent directory
file:
dest: "/etc/haproxy/sites"
owner: root
group: root
mode: "0755"
state: directory
tags:
- haproxy
- 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
file:
dest: "/etc/varnish/sites"
owner: root
group: root
mode: "0755"
state: directory
tags:
- varnish
- 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"
loop: "{{ boost_sites_enabled }}"
loop_control:
loop_var: site
notify: reload varnish
tags:
- varnish
- config
- update-config