Modularize keepalived configs

This commit is contained in:
Salt 2021-03-24 17:49:25 -05:00
parent 059802d326
commit d1252592f1
4 changed files with 40 additions and 29 deletions

View File

@ -31,6 +31,7 @@ all:
kubernetes_role: node
hosts:
pi-kub-node-1.desu.ltd:
keepalived_state: MASTER
keepalived_priority: 50
pi-kub-node-2.desu.ltd:
keepalived_priority: 49

View File

@ -28,6 +28,13 @@
roles:
- role: keepalived
vars:
keepalived_auth_pass: "{{ secret_keepalived_pass }}"
keepalived_vip: "192.168.102.200/16"
keepalived_stanzas:
- name: VI_1
state: "{{ keepalived_state | default('BACKUP') }}"
interface: eth0
virtual_router_id: 51
priority: "{{ keepalived_priority }}"
advert_int: 1
auth_pass: "{{ secret_keepalived_pass }}"
vip: "192.168.102.200/16"
tags: [ k8s, keepalived ]

View File

@ -1,21 +1,22 @@
# vim:ft=ansible:
# Node priority. Should be assigned differently for each host
keepalived_priority: 50
# Node state. Should be "MASTER" on the master and "BACKUP" on backup machines
keepalived_state: "BACKUP"
# The interface to assign the VIP to
keepalived_interface: "eth0"
# The virtual router ID
keepailved_virtual_router_id: 51
# The VIP to pass around. Include the subnet mask like so:
# 192.168.0.5/24
keepalived_vip: ""
# Advertisement interval in seconds
keepalived_advert_int: 1
# Name of the vrrp instance
keepalived_vrrp_instance_name: "VI_1"
# Keepalived authentication password
#keepalived_auth_pass
# A list of stanzas to put in the keepalived.conf file
keepalived_stanzas: []
#keepalived_stanzas:
# # Name of the vrrp instance
# - name: VI_1
# # Node state. Should be "MASTER" on the master and "BACKUP" on backup machines
# state: BACKUP
# # The interface to assign the VIP to
# interface: eth0
# # The virtual router ID
# virtual_router_id: 51
# # Node priority. Should be assigned differently for each host
# priority: 100
# # Advertisement interval in seconds
# advert_int: 1
# # Keepalived authentication password
# auth_pass: mySuperSecretPassword
# # The VIP to pass around. Include the subnet mask like so:
# # 192.168.0.5/24
# vip: 1.2.3.4

View File

@ -1,14 +1,16 @@
vrrp_instance {{ keepalived_vrrp_instance_name }} {
state {{ keepalived_state }}
interface {{ keepalived_interface }}
virtual_router_id {{ keepailved_virtual_router_id }}
priority {{ keepalived_priority }}
advert_int {{ keepalived_advert_int }}
{% for stanza in keepalived_stanzas %}
vrrp_instance {{ stanza.name }} {
state {{ stanza.state | default('BACKUP') }}
interface {{ stanza.interface }}
virtual_router_id {{ stanza.virtual_router_id }}
priority {{ stanza.priority }}
advert_int {{ stanza.advert_int | default('1') }}
authentication {
auth_type PASS
auth_pass {{ keepalived_auth_pass }}
auth_pass {{ stanza.auth_pass }}
}
virtual_ipaddress {
{{ keepalived_vip }}
{{ stanza.vip }}
}
}
{% endfor %}