uZer.keepalived

ansible-role-keepalived

This role installs Keepalived using the apt or yum package manager. It can set up multiple service checks and multiple Virtual IPs (VIPs).

Configuration

You should set all the necessary variables in the host_vars or group_vars files.

Dependencies

This role works on the following operating systems:

  • CentOS
  • Red Hat
  • Ubuntu
  • Debian

Detailed Example

Host Variables

You need to define the role for each host in the host_vars/... file:

keepalived_role:
  "VI_1": "MASTER"  # Can be MASTER or SLAVE
  "VI_2": "MASTER"
  "VI_3": "SLAVE"

Group Variables

Group variables should be set in the group_vars/... file for each Keepalived pod:

keepalived_vrrp_instances:
  "VI_1":
    virtual_router_id: 51      # Label for the interface
    master_priority: 100        # Higher numbers have higher priority
    slave_priority: 50
    shared_iface: eth0
    shared_vips:
      - '10.127.50.3'
    auth_pass: "{{ vault_vrrp_passwords["VI_1"] }}"

  "VI_2":
    virtual_router_id: 52
    master_priority: 100
    slave_priority: 50
    shared_iface: eth0
    shared_vips:
      - '10.127.50.4'
    auth_pass: "{{ vault_vrrp_passwords["VI_2"] }}"

  "VI_3":
    virtual_router_id: 53
    master_priority: 100
    slave_priority: 50
    shared_iface: eth0
    shared_vips:
      - '10.127.50.5'
    auth_pass: "{{ vault_vrrp_passwords["VI_3"] }}"
    checks:
      - chk_nginx
      - chk_keepalived
    settings:
      garp_master_refresh: 20

keepalived_checks:
  "chk_nginx":
    process: nginx              # Check if NGINX is running
    period: 2                   # Check every 2 seconds
  "chk_keepalived":
    script: pgrep keepalived    # Check if Keepalived is running
    period: 2                   # Check every 2 seconds

# In vault:
vault_keepalived_vrrp_passwords:
    "VI_1": 'YUiszRrpLEXbnMLqDapwWLvPAJ'
    "VI_2": 'rJEUkQnmSRahwRTpjUkFVid'
    "VI_3": 'itkcbxmaXwFBiUZJhePmtX'

# OPTIONAL: NOTIFICATION AND SETTINGS
keepalived_advert_interval: 1
keepalived_notify_from: "keepalived@{{ ansible_fqdn }}"
keepalived_notify_smtp_server: "smtp.example.com"
keepalived_notify_smtp_timeout: "30"
keepalived_notify_list:
  - "[email protected]"
  - "[email protected]"
keepalived_global_defs:
  vrrp_garp_master_refresh: 60

Minimum Usage Example

At a minimum, you need to define the following:

Per Host:

keepalived_role:
  "VI_1": "MASTER"

Per Group:

keepalived_vrrp_instances:
  "VI_1":
    virtual_router_id: 10
    shared_iface: eth0
    shared_vips:
      - '10.127.50.5'
    auth_pass: 'NLxQZYzXUfhjkJqWzVrPMua'

License

This project is licensed under "THE (extended) BEER-WARE LICENSE" (Revision 42.0815):

Feel free to do whatever you want with this code as long as you keep this notice. If we ever meet and you think this project is worth it, you can buy me a beer as a thank you.

Author Information

Youenn Piolet

Informazioni sul progetto

Keepalived Configuration

Installa
ansible-galaxy install uZer.keepalived
Licenza
other
Download
3.9k
Proprietario
What year is this?