mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-07-17 17:51:11 +00:00
add keepalived ansible role
This commit is contained in:
parent
7f32475c63
commit
bff88aa1ac
3 changed files with 56 additions and 0 deletions
7
deployment/roles/keepalived/files/check_nginx.sh
Normal file
7
deployment/roles/keepalived/files/check_nginx.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost)
|
||||||
|
|
||||||
|
if [ $STATUS_CODE -lt 200 ] || [ $STATUS_CODE -ge 400 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
25
deployment/roles/keepalived/tasks/main.yml
Normal file
25
deployment/roles/keepalived/tasks/main.yml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
- name: Install keepalived packages
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- keepalived
|
||||||
|
state: latest
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Copy check_nginx script to {{ vrrp_check_nginx_script_path }}
|
||||||
|
copy:
|
||||||
|
src: check_nginx.sh
|
||||||
|
dest: "{{ vrrp_check_nginx_script_path }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Copy keepalived config
|
||||||
|
template:
|
||||||
|
src: keepalived.conf.j2
|
||||||
|
dest: /etc/keepalived/keepalived.conf
|
||||||
|
|
||||||
|
- name: Restart and enable the keepalived service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: keepalived
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
24
deployment/roles/keepalived/templates/keepalived.conf.j2
Normal file
24
deployment/roles/keepalived/templates/keepalived.conf.j2
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
vrrp_script chk_nginx {
|
||||||
|
script "{{ vrrp_check_nginx_script_path }}"
|
||||||
|
interval 5
|
||||||
|
timeout 3
|
||||||
|
weight 2
|
||||||
|
}
|
||||||
|
|
||||||
|
vrrp_instance VI_1 {
|
||||||
|
state MASTER
|
||||||
|
interface {{ vrrp_interface }}
|
||||||
|
virtual_router_id 51
|
||||||
|
priority 100
|
||||||
|
advert_int 1
|
||||||
|
authentication {
|
||||||
|
auth_type PASS
|
||||||
|
auth_pass {{ vrrp_auth_password }}
|
||||||
|
}
|
||||||
|
virtual_ipaddress {
|
||||||
|
{{ vrrp_virtual_ip }} dev {{ vrrp_interface }}
|
||||||
|
}
|
||||||
|
track_script {
|
||||||
|
chk_nginx
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue