Skip to content

Commit 773be92

Browse files
authored
Merge pull request #82 from Marci24h/master
Add haproxy_certstore feature and fix few issues
2 parents 88604dc + f5a95da commit 773be92

File tree

8 files changed

+57
-5
lines changed

8 files changed

+57
-5
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,21 @@ haproxy_ssl_options: no-sslv3 no-tls-tickets force-tlsv12
177177
haproxy_ssl_ciphers: AES128+EECDH:AES128+EDH
178178
haproxy_ssl: 'ssl crt {{ haproxy_ssl_certificate }} ciphers {{ haproxy_ssl_ciphers }} {{ haproxy_ssl_options }}'
179179

180+
## Certificate Storage
181+
haproxy_certstore:
182+
- web:
183+
crt_base: /etc/ssl/
184+
key_base: /etc/ssl/private/
185+
load:
186+
- crt "example.com_fullchain.crt" key "example.com.key" alias "example_com"
187+
- internal:
188+
crt_base: /etc/ssl/
189+
key_base: /etc/ssl/private/
190+
load:
191+
- crt "example.de_fullchain.crt" key "example.de.key" alias "example_de"
192+
193+
haproxy_ssl: 'tfo ssl crt "@web/example_com" alpn h2,http/1.1 ssl-min-ver TLSv1.2'
194+
180195
# Docker
181196
# see more details in `tasks/docker.yml` and https://docs.ansible.com/ansible/latest/collections/community/general/docker_container_module.html
182197
haproxy_docker_name: "haproxy"

handlers/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
ansible.builtin.service:
55
name: "{{ haproxy_service }}"
66
state: restarted
7-
when: haproxy_mode == "system"
7+
when: haproxy_mode == "system" or haproxy_mode == "custom"
88

99
- name: Reload haproxy
1010
ansible.builtin.service:
1111
name: "{{ haproxy_service }}"
1212
state: reloaded
13-
when: haproxy_mode == "system"
13+
when: haproxy_mode == "system" or haproxy_mode == "custom"

tasks/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
# file: roles/haproxy/tasks/config.yml
33
- name: Configuring HAproxy
4+
tags: [haproxy, haproxy-config]
45
ansible.builtin.template:
56
src: etc/haproxy/haproxy.cfg.j2
67
dest: "{{ haproxy_config }}"

tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
- name: Sysctl
3434
include_tasks: sysctl.yml
3535
tags: [haproxy, haproxy-sysctl]
36-
when: haproxy_mode == "system"
36+
when: haproxy_mode == "system" or haproxy_mode == "custom"
3737

3838
- name: Docker
3939
include_tasks: docker.yml

tasks/sysctl.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
---
22
# file: roles/haproxy/tasks/sysctl.yml
3-
- name: Enabling/Disabling net.ipv4.ip_nonlocal_bind option
3+
- name: Enabling/Disabling net.ipvX.ip_nonlocal_bind option
4+
tags: [haproxy, haproxy-sysctl]
45
ansible.posix.sysctl:
5-
name: net.ipv4.ip_nonlocal_bind
6+
name: "{{ item }}"
67
value: "1"
78
sysctl_file: /etc/sysctl.d/10-ip_nonlocal_bind.conf
89
sysctl_set: true
910
reload: true
1011
state: present
12+
with_items:
13+
- net.ipv4.ip_nonlocal_bind
14+
- net.ipv6.ip_nonlocal_bind
1115
notify: Restart haproxy
1216
when: haproxy_bind_nonlocal_ip | bool
1317

1418
- name: Enabling/Disabling net.ipv4.ip_forward option
19+
# tags: [haproxy, haproxy-sysctl]
1520
ansible.posix.sysctl:
1621
name: net.ipv4.ip_forward
1722
value: "1"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{% if haproxy_certstore is defined and haproxy_certstore|length %}
2+
##########################
3+
# Certificate Storage #
4+
##########################
5+
{% for dict_item in haproxy_certstore %}
6+
{% for name, value in dict_item.items() %}
7+
crt-store {{ name }}
8+
{% if value.crt_base is defined %}
9+
crt-base {{ value.crt_base }}
10+
{% endif %}
11+
{% if value.key_base is defined %}
12+
key-base {{ value.key_base }}
13+
{% endif %}
14+
{% if value.load is defined %}
15+
{% for load in value.load %}
16+
load {{ load }}
17+
{% endfor %}
18+
{% endif %}
19+
{% endfor %}
20+
21+
{% endfor %}
22+
{% endif %}

templates/etc/haproxy/haproxy-global.cfg.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ global
2525
gid {{ haproxy_global_gid }}
2626
{% endif %}
2727
maxconn {{ haproxy_global_maxconn | default('4000') }}
28+
{% if ansible_os_family != 'Debian' %}
2829
pidfile {{ haproxy_global_pidfile | default('/var/run/haproxy.pid') }}
30+
{% endif %}
2931
{% if haproxy_global_ca_base is defined and haproxy_global_ca_base | length %}
3032
ca-base {{ haproxy_global_ca_base }}
3133
{% endif %}
@@ -53,6 +55,9 @@ global
5355
{% if haproxy_global_ssl_server_verify is defined and haproxy_global_ssl_server_verify | length %}
5456
ssl-server-verify {{ haproxy_global_ssl_server_verify }}
5557
{% endif %}
58+
{% if haproxy_global_limited_quic is defined and haproxy_global_limited_quic is true %}
59+
limited-quic
60+
{% endif %}
5661
{% if haproxy_global_stats is defined and haproxy_global_stats | length %}
5762
{% for stat in haproxy_global_stats %}
5863
stats {{ stat }}

templates/etc/haproxy/haproxy.cfg.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
{# USERLIST CONFIGURATION #}
1212
{% include 'haproxy-userlist.cfg.j2' %}
13+
14+
{# Certificate Storage #}
15+
{% include 'haproxy-certstore.cfg.j2' %}
16+
1317
{# STATS CONFIGURATION #}
1418
{% include 'haproxy-stats.cfg.j2' %}
1519

0 commit comments

Comments
 (0)