2019-11-08 22:29:11 +01:00
|
|
|
---
|
2020-03-28 18:31:46 +01:00
|
|
|
- name: Converge
|
|
|
|
hosts: all
|
|
|
|
roles:
|
|
|
|
- ansible-role-haproxy
|
2019-11-08 22:29:11 +01:00
|
|
|
vars:
|
|
|
|
haproxy_ssl_certificates:
|
|
|
|
www-example-com: |
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
test
|
2020-04-11 15:34:20 +02:00
|
|
|
haproxy_ips_lists:
|
|
|
|
blacklist:
|
|
|
|
- 172.10.0.0/16
|
|
|
|
- 192.168.1.1
|
2021-08-15 13:00:28 +02:00
|
|
|
haproxy_resolvers:
|
|
|
|
dns:
|
|
|
|
nameserver: dns1 127.0.0.1:53
|
2019-11-08 22:29:11 +01:00
|
|
|
haproxy_frontends:
|
|
|
|
main:
|
|
|
|
bind:
|
|
|
|
ip: '*'
|
|
|
|
port: 5000
|
|
|
|
acl:
|
|
|
|
- url_static path_beg -i /static /images /javascript /stylesheets
|
|
|
|
- url_static path_end -i .jpg .gif .png .css .js
|
|
|
|
frontend-test-https:
|
|
|
|
bind:
|
2020-03-28 18:31:46 +01:00
|
|
|
ip: '*'
|
2019-11-08 22:29:11 +01:00
|
|
|
port: 80
|
|
|
|
mode: http
|
|
|
|
default_backend: backend-test-https
|
|
|
|
option:
|
|
|
|
- 'forwardfor except 127.0.0.0/8'
|
|
|
|
- 'httplog'
|
|
|
|
- 'http-server-close'
|
|
|
|
acl:
|
|
|
|
- acl_test1-https hdr(host) test1.example.net
|
|
|
|
- acl_test2-https hdr(host) test2.example.net
|
2020-04-11 15:34:20 +02:00
|
|
|
- acl_blacklist src -f /etc/haproxy/blacklist.list
|
2019-11-08 22:29:11 +01:00
|
|
|
use_backend:
|
|
|
|
- backend-test-https if acl_test1-https
|
2021-08-15 13:00:28 +02:00
|
|
|
- backend-test-resolver if acl_test2-https
|
2020-04-11 15:34:20 +02:00
|
|
|
- backend-test-https if acl_test1-https acl_blacklist
|
2019-11-08 22:29:11 +01:00
|
|
|
haproxy_backends:
|
|
|
|
backend-test-https:
|
|
|
|
mode: http
|
|
|
|
balance: roundrobin
|
|
|
|
stick-table: type ip size 512k expire 30m
|
|
|
|
stick: on src
|
|
|
|
option:
|
|
|
|
- 'ssl-hello-chk'
|
|
|
|
- 'tcp-check'
|
|
|
|
- 'log-health-checks'
|
|
|
|
- 'forwardfor header X-Forwarded-For'
|
|
|
|
server:
|
|
|
|
- host1 127.0.0.1:443 ssl verify none check maxconn 1000 inter 15s
|
|
|
|
- host2 127.0.0.1:443 ssl verify none check maxconn 1000 inter 15s
|
2021-08-15 13:00:28 +02:00
|
|
|
backend-test-resolver:
|
|
|
|
mode: http
|
|
|
|
balance: roundrobin
|
|
|
|
stick-table: type ip size 512k expire 30m
|
|
|
|
stick: on src
|
|
|
|
option:
|
|
|
|
- 'ssl-hello-chk'
|
|
|
|
server:
|
|
|
|
- google.fr google.com:443 ssl verify none check resolvers dns init-addr none
|
2021-08-15 12:36:58 +02:00
|
|
|
|
|
|
|
pre_tasks:
|
2021-08-15 17:41:47 +02:00
|
|
|
- name: add backports repository
|
|
|
|
ansible.builtin.apt_repository:
|
|
|
|
repo: 'deb http://deb.debian.org/debian {{ ansible_distribution_release }}-backports main'
|
|
|
|
|
2021-08-15 12:36:58 +02:00
|
|
|
- name: update apt cache
|
|
|
|
ansible.builtin.apt:
|
|
|
|
update_cache: true
|