Files
configpolicy/roles/haproxy/tasks/main.yml
Dustin C. Hatch fb9f46cc47 r/haproxy: Do not start service
Since the _haproxy_ role relies on other roles to provide drop-in
configuration files for actual proxy configuration, we cannot start the
service in the base role.  If there are any issues with the drop-in
files that are added later, the service will not be able to start,
causing the playbook to fail and thus never be able to update the broken
configuration.  The dependent roles need to be responsible for starting
the service once they have put their configuration files in place.
2025-07-22 16:21:49 -05:00

62 lines
1.4 KiB
YAML

- name: load distribution-specific values
include_vars: '{{ item }}'
with_first_found:
- '{{ ansible_distribution }}.yml'
- defaults.yml
- name: ensure haproxy is installed
package:
name=haproxy
state=present
tags:
- install
- name: ensure default haproxy configuration file is empty
copy:
src: haproxy.cfg
dest: /etc/haproxy
mode: u=rw,go=r
notify: restart haproxy
- name: ensure haproxy global configuration is set
template:
src: global.cfg.j2
dest: /etc/haproxy/conf.d/10-global.cfg
mode: u=rw,go=r
notify: restart haproxy
- name: ensure haproxy defaults are set
template:
src: defaults.cfg.j2
dest: /etc/haproxy/conf.d/20-defaults.cfg
mode: u=rw,go=r
notify: restart haproxy
- name: ensure haproxy stats frontend is configured
template:
src: stats.cfg.j2
dest: /etc/haproxy/conf.d/30-stats.cfg
mode: u=rw,go=r
notify: reload haproxy
tags:
- config
- stats
- name: ensure haproxy starts at boot
service:
name: haproxy
enabled: true
tags:
- service
- name: ensure firewall is configured for haproxy stats
firewalld:
port: '{{ haproxy_stats_port }}/tcp'
immediate: '{{ item == "immediate" }}'
permanent: '{{ item == "permanent" }}'
state: enabled
loop:
- immediate
- permanent
when: host_uses_firewalld|d(true) and haproxy_enable_stats
tags:
- firewalld
- stats