- name: install haproxy
  apt:
    name: haproxy
    state: present

- name: parametre backend et fontend
  blockinfile:
    path: /etc/haproxy/haproxy.cfg
    block: |
      frontend proxypublic
        bind 192.168.56.2:80
        default_backend fermeweb
      
      backend fermeweb
        balance roundrobin
        option httpclose
        #option httpchk HEAD / HTTP/1.0
        server web1.test 192.168.56.3:80 check
        #server web2.test 192.168.56.4:80 check

- name: redemarre haproxy
  service:
    name: haproxy
    state: restarted
    enabled: yes
