Skip to content

Commit 216fb8e

Browse files
committed
add config
1 parent 50dcf97 commit 216fb8e

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

defaults/main/keepalived.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
---
22
nginx_keepalived_conf_enable: false
3+
nginx_keepalived_conf:
4+
- virtual_router_id: 1
5+
primary_dev: eth0
6+
priority: 101
7+
primary_ip: 192.168.100.100
8+
secondary_ip: 192.168.100.101
9+
cluster_ip: 192.168.100.150

tasks/modules/install-keepalived.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@
66
when:
77
- ansible_facts['os_family'] == 'Alpine'
88
- ansible_facts['distribution'] == 'Amazon'
9+
10+
- name: Configure NGINX Plus keepalived HA
11+
ansible.builtin.template:
12+
src: keepalived/keepalived.conf.tmpl.j2
13+
dest: /etc/keepalived/keepalived.conf
14+
mode: "0644"
15+
when:
16+
- ansible_facts['os_family'] == 'Alpine'
17+
- ansible_facts['distribution'] == 'Amazon'
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{ ansible_managed | comment }}
2+
3+
global_defs {
4+
vrrp_version 3
5+
}
6+
7+
vrrp_script chk_manual_failover {
8+
script "/usr/lib/keepalived/nginx-ha-manual-failover"
9+
interval 10
10+
weight 50
11+
}
12+
13+
vrrp_script chk_nginx_service {
14+
script "/usr/lib/keepalived/nginx-ha-check"
15+
interval 3
16+
weight 50
17+
}
18+
19+
{% for vrrp in nginx_keepalived_conf %}
20+
vrrp_instance VI_{{ vrrp['virtual_router_id'] }} {
21+
interface {{ vrrp['primary_dev'] }}
22+
priority {{ vrrp['priority'] }}
23+
virtual_router_id {{ vrrp['virtual_router_id'] }}
24+
advert_int 1
25+
accept
26+
garp_master_refresh 5
27+
garp_master_refresh_repeat 1
28+
unicast_src_ip {{ vrrp['primary_ip'] }}
29+
unicast_peer {
30+
{{ vrrp['secondary_ip'] }}
31+
}
32+
virtual_ipaddress {
33+
{{ vrrp['cluster_ip'] }}
34+
}
35+
track_script {
36+
chk_nginx_service
37+
chk_manual_failover
38+
}
39+
notify "/usr/lib/keepalived/nginx-ha-notify"
40+
}
41+
{% endfor %}

0 commit comments

Comments
 (0)