--- - name: install haproxy ansible.builtin.apt: name: haproxy state: latest update_cache: true notify: restart haproxy - name: deploy haproxy config ansible.builtin.template: src: "{{ inventory_hostname }}/haproxy.cfg.j2" dest: "/etc/haproxy/haproxy.cfg" owner: root group: root mode: "0644" loop: "{{ query('fileglob', role_path + '/templates/' + inventory_hostname + '/*.cfg.j2') }}" notify: restart haproxy