From 79bfcae37d8370424d08b3f4f308d6e1f5f06c9b Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Mon, 4 Jul 2016 09:26:33 +0200 Subject: [PATCH] ansible-inventories/arocom#143 Allow domains to ignore Varnish --- tasks/configure.yml | 9 +++++++++ templates/haproxy_cfg | 6 ++++-- templates/ignore_varnish_list | 12 ++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 templates/ignore_varnish_list diff --git a/tasks/configure.yml b/tasks/configure.yml index 15adde2..8a3b9d5 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -29,6 +29,15 @@ with_items: '{{ groups.all }}' notify: 'Proxy | Restart HAProxy' +- name: "Proxy | Create ignore varnish host lists" + template: + src='ignore_varnish_list' + dest='/etc/haproxy/ignore_varnish.list' + owner='root' + group='root' + mode='644' + notify: 'Proxy | Restart HAProxy' + - name: "Proxy | Create empty crm lists files" file: dest='/etc/haproxy/{{item}}.crm.list' diff --git a/templates/haproxy_cfg b/templates/haproxy_cfg index 4e49002..c0a61d1 100644 --- a/templates/haproxy_cfg +++ b/templates/haproxy_cfg @@ -84,8 +84,9 @@ frontend http_in use_backend backend_redirect_ssl if kibana_present {% endif %} {% if varnish_host|default(false) %} + acl domain_ignores_varnish hdr(host) -i -n -f /etc/haproxy/ignore_varnish.list acl static_content path_end .jpg .jpeg .gif .png .ico .swf .css .js .htm .html - use_backend backend_varnish if static_content + use_backend backend_varnish if static_content !domain_ignores_varnish {% endif %} {% for host in groups['all'] %} acl domain_in_{{host}} hdr(host) -i -n -f /etc/haproxy/{{host}}.list @@ -137,8 +138,9 @@ frontend https_in_{{ cert.ip }} use_backend backend_{{ external.key }} if is_{{ external.key }} {% endfor %} {% if varnish_host|default(false) %} + acl domain_ignores_varnish hdr(host) -i -n -f /etc/haproxy/ignore_varnish.list acl static_content path_end .jpg .jpeg .gif .png .ico .swf .css .js .htm .html - use_backend backend_varnish if static_content + use_backend backend_varnish if static_content !domain_ignores_varnish {% endif %} {% for host in groups['all'] %} acl ssl_domain_in_{{host}} hdr(host) -i -n -f /etc/haproxy/{{host}}.ssl.list diff --git a/templates/ignore_varnish_list b/templates/ignore_varnish_list new file mode 100644 index 0000000..207c9cc --- /dev/null +++ b/templates/ignore_varnish_list @@ -0,0 +1,12 @@ +{% for item in groups.all %} +{% for domain in hostvars[item].proxy_domains_ignore_varnish|default([]) %} +{{domain}} +{% endfor %} +{% for drupal in hostvars[item].drupal_settings|default([]) %} +{% for domain in drupal.domains|default([]) %} +{% if domain.ignore_varnish|default(false) %} +{{domain.domain}} +{% endif %} +{% endfor %} +{% endfor %} +{% endfor %} -- GitLab