--- - name: Install haproxy command: > bash -c "apt-get update -qq apt-get install -y -qq haproxy" become: true - name: Copy haproxy config template: src: ../roles/haproxy/templates/haproxy.cfg.j2 dest: /etc/haproxy/haproxy.cfg register: haproxy_cfg become: true - name: Set haproxy.cfg permissions file: path: /etc/haproxy/haproxy.cfg mode: 0644 become: true - name: Set haproxy as enabled lineinfile: path: /etc/default/haproxy regexp: '^ENABLED=' line: 'ENABLED=1' become: true - name: Restart haproxy if /etc/haproxy/haproxy.cfg or /etc/default/haproxy changes. service: name: haproxy state: restarted when: haproxy_cfg.changed become: true