- name: setup haproxy gather_facts: no hosts: "{{target}}" become: "{{become}}" tasks: # # setup haproxy # - name: deploy haproxy config ansible.builtin.template: src: templates/haproxy.cfg.j2.{{env}} dest: /etc/haproxy/haproxy.cfg notify: reload haproxy diff: true # todo avoid redundancy with reload haproxy handler - name: Ensure HAProxy is started and enabled on boot. service: name=haproxy state=started enabled=yes handlers: #- name: reload haproxy # ansible.builtin.shell: # executable: /bin/bash # # stdout: Configuration file is valid # cmd: "[[ -n `haproxy -f /etc/haproxy/haproxy.cfg -c -V 2>/dev/null | grep valid$'` ]] && systemctl reload haproxy.service" # starts the daemon implicitly - name: reload haproxy service: name=haproxy state=reloaded