ansible-role-haproxy/tasks/main.yml

73 lines
1.6 KiB
YAML
Raw Permalink Normal View History

2019-11-08 21:29:11 +00:00
---
2023-07-25 13:25:57 +00:00
- name: Install package
ansible.builtin.apt:
2021-08-15 10:38:44 +00:00
name:
- haproxy
2023-07-25 13:25:57 +00:00
default_release: "{{ haproxy_apt_release }}"
2019-11-08 21:29:11 +00:00
tags: haproxy
2023-07-25 13:25:57 +00:00
- name: Copy ssl certificates
2021-08-15 10:38:44 +00:00
ansible.builtin.copy:
2023-07-25 13:25:57 +00:00
content: "{{ item.value }}"
dest: "/etc/haproxy/{{ item.key }}.pem"
2019-11-08 21:29:11 +00:00
owner: root
group: root
2023-07-25 13:25:57 +00:00
mode: "0600"
loop: "{{ haproxy_ssl_certificates | dict2items }}"
2019-11-08 21:29:11 +00:00
no_log: true
2023-07-25 13:25:57 +00:00
notify: Reload haproxy
2019-11-08 21:29:11 +00:00
tags: haproxy
2023-07-25 13:25:57 +00:00
- name: Copy IPs lists
2021-08-15 10:38:44 +00:00
ansible.builtin.copy:
2023-07-25 13:25:57 +00:00
content: "{{ item.value | join('\n') }}"
dest: "/etc/haproxy/{{ item.key }}.list"
2020-04-11 13:34:20 +00:00
owner: root
group: root
2023-07-25 13:25:57 +00:00
mode: "0644"
loop: "{{ haproxy_ips_lists | dict2items }}"
2020-04-11 13:34:20 +00:00
loop_control:
2023-07-25 13:25:57 +00:00
label: "{{ item.key }}"
notify: Reload haproxy
2020-04-11 13:34:20 +00:00
tags: haproxy
2023-07-25 13:25:57 +00:00
- name: Create http errors directory
2021-12-06 09:30:21 +00:00
ansible.builtin.file:
2023-07-25 13:25:57 +00:00
path: "/etc/haproxy/errors"
2021-12-06 09:30:21 +00:00
owner: root
group: root
2023-07-25 13:25:57 +00:00
mode: "0755"
2021-12-06 09:30:21 +00:00
state: directory
tags: haproxy
2023-07-25 13:25:57 +00:00
- name: Copy http errors file
2021-12-06 09:30:21 +00:00
ansible.builtin.copy:
2023-07-25 13:25:57 +00:00
content: "{{ item.value }}"
dest: "/etc/haproxy/errors/{{ item.key }}.http"
2021-12-06 09:30:21 +00:00
owner: root
group: root
mode: 0644
2023-07-25 13:25:57 +00:00
loop: "{{ haproxy_http_error_files | dict2items }}"
2021-12-06 09:30:21 +00:00
loop_control:
2023-07-25 13:25:57 +00:00
label: "{{ item.key }}"
notify: Reload haproxy
2021-12-06 09:30:21 +00:00
tags: haproxy
2023-07-25 13:25:57 +00:00
- name: Copy config file
2021-08-15 10:38:44 +00:00
ansible.builtin.template:
2019-11-08 21:29:11 +00:00
src: haproxy.cfg.j2
dest: /etc/haproxy/haproxy.cfg
owner: root
group: root
2023-07-25 13:25:57 +00:00
mode: "0640"
2019-11-08 21:29:11 +00:00
validate: haproxy -c -f %s
2023-07-25 13:25:57 +00:00
notify: Reload haproxy
2019-11-08 21:29:11 +00:00
tags: haproxy
2023-07-25 13:25:57 +00:00
- name: Enable ans start service
2021-08-15 10:38:44 +00:00
ansible.builtin.service:
2019-11-08 21:29:11 +00:00
name: haproxy
enabled: true
state: started
tags: haproxy