--- # file: roles/haproxy/handler/main.yml - name: Check HAProxy Config command: haproxy -c -f /etc/haproxy/haproxy.cfg register: haproxy_config_check changed_when: "Configuration file is valid" in haproxy_config_check.stdout_lines failed_when: "Configuration file is valid" not in haproxy_config_check.stdout_lines notify: "Restart HAProxy" - name: Restart HAProxy service: name={{item.name}} state={{item.state}} with_items: - name: haproxy state: restarted