ansible-role-haproxy/tasks/main.yml

54 lines
1.1 KiB
YAML
Raw Normal View History

2019-11-08 21:29:11 +00:00
---
- name: install package
ansible.builtin.apt:
2021-08-15 10:38:44 +00:00
name:
- haproxy
default_release: '{{ haproxy_apt_release }}'
2019-11-08 21:29:11 +00:00
retries: 2
register: result
until: result is succeeded
tags: haproxy
- name: copy ssl certificates
2021-08-15 10:38:44 +00:00
ansible.builtin.copy:
2019-11-08 21:29:11 +00:00
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
2019-11-08 21:29:11 +00:00
tags: haproxy
2020-04-11 13:34:20 +00:00
- name: copy IPs lists
2021-08-15 10:38:44 +00:00
ansible.builtin.copy:
2020-04-11 13:34:20 +00:00
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
2019-11-08 21:29:11 +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
mode: 0640
validate: haproxy -c -f %s
notify: reload haproxy
tags: haproxy
- 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