Skip to content
Snippets Groups Projects
Commit 89e4849f authored by jurgenhaas's avatar jurgenhaas
Browse files

Enhance haproxy installation

parent d789af60
No related branches found
No related tags found
No related merge requests found
default_proxy: '' default_proxy: ''
proxy_default_backend: '' proxy_default_backend: ''
proxy_certificates: []
proxy_blacklist_ips: [] proxy_blacklist_ips: []
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
owner=root owner=root
group=root group=root
mode=644 mode=644
when: scope == 'all' #when: scope == 'all'
with_items: '{{ groups.all }}' with_items: '{{ groups.all }}'
notify: 'Proxy | Restart HAProxy' notify: 'Proxy | Restart HAProxy'
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
owner=root owner=root
group=root group=root
mode=644 mode=644
when: scope == 'all' #when: scope == 'all'
with_items: '{{ groups.all }}' with_items: '{{ groups.all }}'
notify: 'Proxy | Restart HAProxy' notify: 'Proxy | Restart HAProxy'
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
group=root group=root
mode=644 mode=644
state=touch state=touch
when: scope == 'all' #when: scope == 'all'
with_items: '{{ groups.all }}' with_items: '{{ groups.all }}'
notify: 'Proxy | Restart HAProxy' notify: 'Proxy | Restart HAProxy'
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
owner=root owner=root
group=root group=root
mode=644 mode=644
when: scope == 'all' #when: scope == 'all'
notify: 'Proxy | Restart HAProxy' notify: 'Proxy | Restart HAProxy'
- name: "Proxy | Install update php script" - name: "Proxy | Install update php script"
...@@ -74,5 +74,5 @@ ...@@ -74,5 +74,5 @@
owner=root owner=root
group=root group=root
mode=644 mode=644
when: scope == 'all' #when: scope == 'all'
notify: 'Proxy | Restart HAProxy' notify: 'Proxy | Restart HAProxy'
{% for line in hostvars[item]['proxy_blacklist_ips'] %} {% for host in groups['all'] %}
{% for line in hostvars[host].proxy_blacklist_ips|default([]) %}
{{line}} {{line}}
{% endfor %} {% endfor %}
{% endfor %}
...@@ -46,55 +46,53 @@ frontend http-in ...@@ -46,55 +46,53 @@ frontend http-in
acl blockedip src -i -f /etc/haproxy/blacklist acl blockedip src -i -f /etc/haproxy/blacklist
http-request deny if blockedip http-request deny if blockedip
{% for host in groups['all'] %} {% for host in groups['all'] %}
{% if hostvars[host]['proxy_redirect'] %} {% for redirect in hostvars[host].proxy_redirect|default([]) %}
{% for redirect in hostvars[host]['proxy_redirect'] %}
redirect prefix http://{{redirect.to}} if { hdr_dom(host) -i {{redirect.from}} } redirect prefix http://{{redirect.to}} if { hdr_dom(host) -i {{redirect.from}} }
{% endfor %} {% endfor %}
{% endif %}
{% endfor %} {% endfor %}
{% for host in groups['all'] %} {% for host in groups['all'] %}
{% if hostvars[host]['proxy_domains'] %} {% if hostvars[host].proxy_domains is defined %}
acl domain_in_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.list acl domain_in_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.list
use_backend backend_{{host}} if domain_in_{{host}} use_backend backend_{{host}} if domain_in_{{host}}
{% endif %} {% endif %}
{% if hostvars[host]['proxy_crm_domains'] %} {% if hostvars[host].proxy_crm_domains is defined %}
acl crm_domain_in_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.crm.list acl crm_domain_in_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.crm.list
use_backend backend_{{host}} if crm_domain_in_{{host}} use_backend backend_{{host}} if crm_domain_in_{{host}}
{% endif %} {% endif %}
{% if hostvars[host]['proxy_ssl_domains'] %} {% if hostvars[host].proxy_ssl_domains is defined %}
acl redirect_ssl_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.ssl.list acl redirect_ssl_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.ssl.list
use_backend backend_redirect_ssl if redirect_ssl_{{host}} use_backend backend_redirect_ssl if redirect_ssl_{{host}}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% for cert in proxy_certificates %}
frontend https-in frontend https-in
bind :443 ssl crt /etc/haproxy/certs/s-verein.de.pem no-sslv3 bind :443 ssl crt /etc/haproxy/certs/{{ cert }} no-sslv3
acl blockedip src -i -f /etc/haproxy/blacklist acl blockedip src -i -f /etc/haproxy/blacklist
http-request deny if blockedip http-request deny if blockedip
{% for host in groups['all'] %} {% for host in groups['all'] %}
{% if hostvars[host]['proxy_redirect'] %} {% for redirect in hostvars[host].proxy_redirect|default([]) %}
{% for redirect in hostvars[host]['proxy_redirect'] %}
redirect prefix https://{{redirect.to}} if { hdr_dom(host) -i {{redirect.from}} } redirect prefix https://{{redirect.to}} if { hdr_dom(host) -i {{redirect.from}} }
{% endfor %} {% endfor %}
{% endif %}
{% endfor %} {% endfor %}
{% for host in groups['all'] %} {% for host in groups['all'] %}
{% if hostvars[host]['proxy_ssl_domains'] %} {% if hostvars[host].proxy_ssl_domains is defined %}
acl ssl_domain_in_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.ssl.list acl ssl_domain_in_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.ssl.list
use_backend backend_{{host}} if ssl_domain_in_{{host}} use_backend backend_{{host}} if ssl_domain_in_{{host}}
{% endif %} {% endif %}
{% if hostvars[host]['proxy_domains'] %} {% if hostvars[host].proxy_domains is defined %}
acl redirect_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.list acl redirect_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.list
use_backend backend_redirect if redirect_{{host}} use_backend backend_redirect if redirect_{{host}}
{% endif %} {% endif %}
{% if hostvars[host]['proxy_crm_domains'] %} {% if hostvars[host].proxy_crm_domains is defined %}
acl crm_redirect_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.list acl crm_redirect_{{host}} hdr_dom(host) -i -f /etc/haproxy/{{host}}.list
use_backend backend_redirect if crm_redirect_{{host}} use_backend backend_redirect if crm_redirect_{{host}}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endfor %}
{% for host in groups['all'] %} {% for host in groups['all'] %}
{% if (hostvars[host]['proxy_domains']) or (hostvars[host]['proxy_ssl_domains']) or (hostvars[host]['proxy_crm_domains']) %} {% if (hostvars[host].proxy_domains is defined) or (hostvars[host].proxy_ssl_domains is defined) or (hostvars[host].proxy_crm_domains is defined) %}
backend backend_{{host}} backend backend_{{host}}
server server_{{host}} {{hostvars[host]['ansible_default_ipv4']['address']|default(hostvars[host]['static_ipv4'])}}:80 maxconn 32 server server_{{host}} {{hostvars[host]['ansible_default_ipv4']['address']|default(hostvars[host]['static_ipv4'])}}:80 maxconn 32
......
{% for domain in hostvars[item]['proxy_domains'] %} {% for domain in hostvars[item].proxy_domains|default([]) %}
{{domain}} {{domain}}
{% endfor %} {% endfor %}
{% for domain in hostvars[item]['proxy_ssl_domains'] %} {% for domain in hostvars[item].proxy_ssl_domains|default([]) %}
{{domain}} {{domain}}
{% endfor %} {% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment