-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Install and configure NGINX Plus HA keepalived package (#764)
* And add validation support for NGINX modules while at it
- Loading branch information
Showing
9 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
# Install NGINX Plus HA keepalived package | ||
nginx_keepalived_enable: false | ||
|
||
# Configure NGINX Plus HA keepalived | ||
nginx_keepalived_conf_enable: false | ||
nginx_keepalived_conf: | ||
- virtual_router_id: 1 | ||
primary_dev: eth0 | ||
priority: 101 | ||
primary_ip: 192.168.100.100 | ||
secondary_ip: | ||
- 192.168.100.101 | ||
cluster_ip: | ||
- 192.168.100.150 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Install NGINX Plus HA keepalived package | ||
ansible.builtin.package: | ||
name: nginx-ha-keepalived | ||
state: present | ||
when: | ||
- nginx_keepalived_enable | bool | ||
- ansible_facts['os_family'] != 'Alpine' | ||
- ansible_facts['distribution'] != 'Amazon' | ||
notify: (Handler) Start NGINX Plus HA keepalived | ||
|
||
- name: Configure NGINX Plus keepalived HA | ||
ansible.builtin.template: | ||
src: keepalived/keepalived.conf.tmpl.j2 | ||
dest: /etc/keepalived/keepalived.conf | ||
mode: "0644" | ||
when: | ||
- nginx_keepalived_conf_enable | bool | ||
- ansible_facts['os_family'] != 'Alpine' | ||
- ansible_facts['distribution'] != 'Amazon' | ||
notify: (Handler) Start NGINX Plus HA keepalived |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{ ansible_managed | comment }} | ||
|
||
global_defs { | ||
vrrp_version 3 | ||
} | ||
|
||
vrrp_script chk_manual_failover { | ||
script "/usr/lib/keepalived/nginx-ha-manual-failover" | ||
interval 10 | ||
weight 50 | ||
} | ||
|
||
vrrp_script chk_nginx_service { | ||
script "/usr/lib/keepalived/nginx-ha-check" | ||
interval 3 | ||
weight 50 | ||
} | ||
|
||
{% for vrrp in nginx_keepalived_conf %} | ||
vrrp_instance VI_{{ vrrp['virtual_router_id'] }} { | ||
interface {{ vrrp['primary_dev'] }} | ||
priority {{ vrrp['priority'] }} | ||
virtual_router_id {{ vrrp['virtual_router_id'] }} | ||
advert_int 1 | ||
accept | ||
garp_master_refresh 5 | ||
garp_master_refresh_repeat 1 | ||
unicast_src_ip {{ vrrp['primary_ip'] }} | ||
unicast_peer { | ||
{% for ip in vrrp['secondary_ip'] %} | ||
{{ ip }} | ||
{% endfor %} | ||
} | ||
virtual_ipaddress { | ||
{% for ip in vrrp['cluster_ip'] %} | ||
{{ ip }} | ||
{% endfor %} | ||
} | ||
track_script { | ||
chk_nginx_service | ||
chk_manual_failover | ||
} | ||
notify "/usr/lib/keepalived/nginx-ha-notify" | ||
} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters