--- - name: Get the haproxy repo key apt_key: url=http://haproxy.debian.net/bernat.debian.org.gpg state=present when: haproxy_latest_release register: haproxy_repo tags: haproxy - name: Define the haproxy repository apt_repository: repo='{{ haproxy_latest_repo }}' state=present when: haproxy_latest_release register: haproxy_repo tags: haproxy - name: Update the apt cache if needed apt: update_cache=yes when: ( haproxy_repo | changed ) tags: haproxy - name: Install the haproxy package apt: name=haproxy state=latest default_release={{ ansible_distribution}}-backports when: not haproxy_latest_release tags: haproxy - name: Install the haproxy package apt: name=haproxy state=latest default_release={{ ansible_distribution}}-backports-{{ haproxy_version }} when: not haproxy_latest_release tags: haproxy