Configure keepalived with Ansible the way you want
Add optionnal section keepalived_vrrp_sync_group (#6)
Add a molecule scenario for bullseye
Refer to bullseye support in meta/main.yml



You can also use your local clone with git send-email.


builds.sr.ht status

This role configures keepalived without arm twisting. Write the configuration the way you want.

Automatic testing is provided using molecule's delegated driver and https://builds.sr.ht.


Another role or deployment method must be devised to use notification scripts such as notify_backup, notify_fault and notify_master.

#Role Variables

  • keepalived_global_defs: configure the global_defs block ;
  • keepalived_vrrp_scripts: configure one or more vrrp_script ;
  • keepalived_vrrp_instances: configure one or more vrrp_instance.
  • keepalived_virtual_servers: configure one or more virtual_servers.
  • keepalived_vrrp_sync_group: configure one or more vrrp_sync_group.
  • keepalived_flags: flags to pass to the keepalived daemon (set --log-detail --log-facility=7 by default)


The keepalived package should be installed first using a tool such as Packer. However if it is not part of your toolchain the variable keepalived_install can be set to True to provoke an installation.

#Example Playbook

- hosts: wwwmaster
    - keepalived_global_defs: |
        router_id 1
    - keepalived_vrrp_scripts:
        - name: haproxy
          content: |
            script "killall -0 haproxy"
    - keepalived_vrrp_instances:
        - name: HAPROXY
          content: |
            virtual_router_id 42
            state MASTER
            unicast_src_ip "{{ master_ip }}"
            unicast_peer {
              "{{ backup_ip }}"
            interface eth0
            virtual_ipaddress {
              "{{ vip_front }}"
            track_script {
    - keepalived_vrrp_sync_group:
        - name: VRRP-GRP-01
            - HAPROXY
            - WEB
    - role: ansible-keepalived




Either send send GitHub pull requests or send patches on SourceHut.

#Author Information

This role was created in 2018 by Tristan Le Guern on the behalf of Deveryware.