File tree Expand file tree Collapse file tree 4 files changed +63
-0
lines changed Expand file tree Collapse file tree 4 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
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
Original file line number Diff line number Diff line change 66
66
- logrotate_check['stderr_lines'] != []
67
67
- logrotate_check['rc'] != 0
68
68
listen : (Handler) Run logrotate
69
+
70
+ - name : (Handler) Start NGINX Plus HA keepalived
71
+ ansible.builtin.service :
72
+ name : keepalived
73
+ state : restarted
74
+ enabled : true
Original file line number Diff line number Diff line change 6
6
when :
7
7
- ansible_facts['os_family'] == 'Alpine'
8
8
- 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'
Original file line number Diff line number Diff line change
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 %}
You can’t perform that action at this time.
0 commit comments