ansible-role-haproxy/tasks/main.yml
2024-03-13 21:19:38 +01:00

72 lines
1.6 KiB
YAML

---
- name: Install package
ansible.builtin.apt:
name:
- haproxy
default_release: "{{ haproxy_apt_release }}"
tags: haproxy
- name: Copy ssl certificates
ansible.builtin.copy:
content: "{{ item.value }}"
dest: "/etc/haproxy/{{ item.key }}.pem"
owner: root
group: root
mode: "0600"
loop: "{{ haproxy_ssl_certificates | dict2items }}"
no_log: true
notify: Reload haproxy
tags: haproxy
- name: Copy IPs lists
ansible.builtin.copy:
content: "{{ item.value | join('\n') }}"
dest: "/etc/haproxy/{{ item.key }}.list"
owner: root
group: root
mode: "0644"
loop: "{{ haproxy_ips_lists | dict2items }}"
loop_control:
label: "{{ item.key }}"
notify: Reload haproxy
tags: haproxy
- name: Create http errors directory
ansible.builtin.file:
path: "/etc/haproxy/errors"
owner: root
group: root
mode: "0755"
state: directory
tags: haproxy
- name: Copy http errors file
ansible.builtin.copy:
content: "{{ item.value }}"
dest: "/etc/haproxy/errors/{{ item.key }}.http"
owner: root
group: root
mode: 0644
loop: "{{ haproxy_http_error_files | dict2items }}"
loop_control:
label: "{{ item.key }}"
notify: Reload haproxy
tags: haproxy
- name: Copy config file
ansible.builtin.template:
src: haproxy.cfg.j2
dest: /etc/haproxy/haproxy.cfg
owner: root
group: root
mode: "0640"
validate: haproxy -c -f %s
notify: Reload haproxy
tags: haproxy
- name: Enable ans start service
ansible.builtin.service:
name: haproxy
enabled: true
state: started
tags: haproxy