Skip to content

Commit 37d4404

Browse files
authored
Merge pull request #250 from stfc/update_haproxy
ENH: Update HAProxy to use self-signed certificates
2 parents 84106a9 + 30f1615 commit 37d4404

File tree

2 files changed

+35
-24
lines changed

2 files changed

+35
-24
lines changed

chatops_deployment/ansible/roles/haproxy/tasks/haproxy.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,31 @@
2121
path: /etc/haproxy/{{ domain }}.crt
2222
register: haproxy_certificate_file
2323

24+
- name: Create ssl directory to store self signed certificates
25+
become: true
26+
ansible.builtin.file:
27+
path: /etc/haproxy/ssl
28+
state: directory
29+
owner: root
30+
group: haproxy
31+
mode: "0774"
32+
33+
- name: Copy service self signed certificates
34+
become: true
35+
ansible.builtin.copy:
36+
src: "./{{ env }}_ssl/{{ item }}.crt"
37+
dest: "/etc/haproxy/ssl/{{ item }}.crt"
38+
owner: root
39+
group: haproxy
40+
mode: "0440"
41+
loop:
42+
- grafana
43+
- kibana
44+
- elasticsearch
45+
- prometheus
46+
- alertmanager
47+
- chatops
48+
2449
- name: Make sure haproxy.service is running
2550
become: true
2651
ansible.builtin.systemd_service:

chatops_deployment/ansible/roles/haproxy/templates/haproxy.cfg.j2

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ bind *:443 ssl crt /etc/haproxy/{{ domain }}.crt
4040
stats enable
4141
stats uri /stats
4242
stats refresh 10s
43-
http-request add-header X-Forwarded-Proto https
43+
http-request add-header X-Forwarded-Proto https
44+
http-request add-header X-Forwarded-Port 443
4445
redirect scheme https if !{ ssl_fc }
46+
option forwardfor
4547

4648
acl grafana hdr_sub(host) -i grafana.{{ domain }}
4749
acl prometheus hdr_sub(host) -i prometheus.{{ domain }}
@@ -64,35 +66,19 @@ frontend PROMETHEUS
6466

6567
backend GRAFANA
6668
balance source
67-
{% for address in groups['grafana'] %}
68-
{% if loop.first %}
69-
server grafana_{{ loop.index }} {{ address }}:3000 check
70-
{% else %}
71-
server grafana_{{ loop.index }} {{ address }}:3000 check backup
72-
{% endif %}
73-
{% endfor %}
69+
server grafana localhost:3000 check ssl verify required ca-file /etc/haproxy/ssl/grafana.crt
7470

7571
backend PROMETHEUS
7672
balance source
77-
{% for address in groups['prometheus'] %}
78-
server prometheus_{{ loop.index }} {{ address }}:9090 check
79-
{% endfor %}
73+
server prometheus localhost:9090 check ssl verify required ca-file /etc/haproxy/ssl/prometheus.crt
8074

8175
backend ALERTMANAGER
82-
{% for address in groups['prometheus'] %}
83-
server alertmanager_{{ loop.index }} {{ address }}:9093 check
84-
{% endfor %}
76+
server alertmanager localhost:9093 check ssl verify required ca-file /etc/haproxy/ssl/alertmanager.crt
8577

8678
backend CHATOPS
87-
{% for address in groups['chatops'] %}
88-
{% if loop.last %}
89-
server chatops_{{ loop.index }} {{ address }}:3000 check backup
90-
{% else %}
91-
server chatops_{{ loop.index }} {{ address }}:3000 check
92-
{% endif %}
93-
{% endfor %}
79+
server chatops_0 localhost:3030 check
80+
server chatops_1 localhost:3031 check
81+
server chatops_2 localhost:3032 check backup
9482

9583
backend KIBANA
96-
{% for address in groups['elastic'] %}
97-
server elastic_{{ loop.index }} {{ address }}:5601 check
98-
{% endfor %}
84+
server kibana localhost:5601 check ssl verify required ca-file /etc/haproxy/ssl/kibana.crt

0 commit comments

Comments
 (0)