---
- stat: path=/etc/haproxy/haproxy.cfg
  register: haproxy_cfg

- name: Copy HAProxy configuration in place.
  template:
    src: haproxy.cfg.j2
    dest: /etc/haproxy/haproxy.cfg
    mode: 0644
    validate: haproxy -f %s -c -q
  notify: restart haproxy
  when: haproxy_cfg.stat.exists == True
