Ansible role to set up Keepalived in a high availability and scalability context.
Currently supported platforms are:
- Ubuntu 20.04 LTS
- Ubuntu 22.04 LTS
- Ubuntu 24.04 LTS
None.
Set the unicast peer IP addresses of the Keepalived instance:
keepalived_unicast_peers:
- '192.168.33.15'
- '192.168.33.16'
Set the virtual IP address of the Keepalived instance:
keepalived_virtual_ip_address: '192.168.33.100'
If you need to configure multiple virtual IP addresses you can define this
optional variable. This takes precedence over keepalived_virtual_ip_address
.
keepalived_virtual_ipaddress_configs:
- "10.0.10.15 dev eth0"
- "10.0.11.15 dev eht1"
Variable to pin the Keepalived version to a certain value:
keepalived_version: '2.3.1'
List of Keepalived dependencies to be installed:
keepalived_dependencies:
- 'build-essential'
- 'curl'
- 'gcc'
- 'libssl-dev'
- 'libnl-3-dev'
- 'libnl-genl-3-dev'
- 'libsnmp-dev'
Path to the Keepalived executable:
keepalived_executable_path: '/usr/local/sbin/keepalived'
URL from which Keepalived can be downloaded:
keepalived_download_url: 'https://www.keepalived.org/software/keepalived-{{ keepalived_version }}.tar.gz'
Name of the template file for Keepalived configuration file
keepalived_conf_template: 'keepalived.conf.j2'
Directory which contains Keepalived configuration files:
keepalived_conf_dir: '/etc/keepalived'
Path to Keepalived configuration file:
keepalived_conf_file_path: '/etc/keepalived/keepalived.conf'
Path to Keepalived sysconfig file:
keepalived_sysconfig_file_path: "/etc/keepalived/keepalived.sysconfig"
Name of the template file for Systemd service:
keepalived_service_template: 'keepalived.service.j2'
Path to Keepalived service file:
keepalived_service_file_path: '/etc/systemd/system/keepalived.service'
Path to the Keepalived PID file:
keepalived_pid_file_path: "/run/keepalived/keepalived.pid"
Configure recipient of notification emails:
keepalived_notification_email: 'name@localhost'
Configure sender of notification emails:
keepalived_notification_email_from: 'keepalived@localhost'
Configure IP address or FQDN of SMTP server:
keepalived_smtp_server: '127.0.0.1'
Set the state of the Keepalived instance to MASTER or BACKUP:
keepalived_state: 'BACKUP'
Set the priority of the Keepalived instance:
keepalived_priority: '99'
Maximum priority to which Keepalived can automatically increase (must be in range [0, 99] or -1 to disable):
keepalived_max_auto_priority: '99'
Set unique name of the Keepalived router:
keepalived_router_id: 'KEEPALIVED_2'
Adjust the priority by this weight:
keepalived_weight: '0'
Set the unicast source IP address of the Keepalived instance:
keepalived_unicast_src_ip: '{{ ansible_default_ipv4.address }}'
Set network interface to which the floating IP address is associated:
keepalived_interface: "{{ ansible_default_ipv4.interface }}"
Set the virtual IP address and network interface of the Keepalived instance:
keepalived_virtual_ipaddress_config: "{{ keepalived_virtual_ip_address }} dev {{ keepalived_interface }}"
Set the authentication password of the Keepalived instance:
keepalived_auth_pass: 'changeme'
Flag to enable script security to prevent script to run by root user if any part of the path is writable by a non-root user:
keepalived_set_script_security_flag: true
Specify username to run Keepalived script under:
keepalived_script_user: 'haproxy'
Specify groupname to run Keepalived script under:
keepalived_script_group: 'haproxy'
Activate process tracking in keepalived config:
keepalived_enable_process_tracking: true
keepalived_track_process: 'haproxy'
Activate script that is executed by Keepalived:
keepalived_activate_script: false
Specify the script name to be executed by Keepalived:
keepalived_script_name: 'chk_haproxy_process'
Specify the command to be executed by Keepalived:
keepalived_script_command: '/usr/bin/killall -0 haproxy'
None.
Note: This role is intended for use with, but not limited to, the hifis.haproxy role.
- hosts: loadbalancers
roles:
- role: hifis.toolkit.keepalived
vars:
keepalived_virtual_ip_address: '192.168.33.100'
keepalived_unicast_peers:
- '192.168.33.15'
- '192.168.33.16'
This role was created by HIFIS Software Services