--- - block: - name: Install the keepalived repository apt_repository: repo={{ keepalived_repo }} - name: Install the keepalived package apt: name={{ item }} state={{ keepalived_pkg_state }} update_cache=yes with_items: '{{ keepalived_pkgs }}' - name: Install the keepalived configuration template: src=keepalived.conf.j2 dest=/etc/keepalived/keepalived.conf notify: restart keepalived - name: Ensure that keepalived is started and enabled service: name=keepalived state=started enabled=yes when: keepalived_enabled - name: Ensure that keepalived is stopped and disabled service: name=keepalived state=stopped enabled=no when: not keepalived_enabled tags: keepalived when: keepalived_install - block: - name: Remove the keepalived package if we do not want it apt: name={{ item }} state=absent with_items: '{{ keepalived_pkgs }}' tags: keepalived when: not keepalived_install