Add first version of Keepalived role
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
17f1a1a55e
commit
58f82046cc
|
@ -0,0 +1,16 @@
|
|||
# keepalived
|
||||
|
||||
Install Keepalived
|
||||
|
||||
## Tasks
|
||||
|
||||
Everything is in the `tasks/main.yml` file.
|
||||
|
||||
## Available variables
|
||||
|
||||
* `keepalived_interface` : Interface used by vrrpd instance (default is the interface reported by ansible_default_ipv4.interface)
|
||||
* `keepalived_role` : This can be either master or backup (default: `master`)
|
||||
* `keepalived_router_id` : Number between 0 and 255 used to differentiate multiple instances of vrrpd (default: `42`)
|
||||
* `keepalived_priority` : Used for electing MASTER, highest priority wins (default : `100` when keepalived_role is set to `master` otherwise `50`)
|
||||
* `keepalived_ip` : Address added or deleted on change to MASTER/BACKUP. This is mandatory (default: none)
|
||||
* `keepalived_password` : Password for accessing vrrpd. Should be the same on all machines. This is mandatory (default: none)
|
|
@ -0,0 +1,6 @@
|
|||
keepalived_interface: "{{ ansible_default_ipv4.interface }}"
|
||||
keepalived_role: "master"
|
||||
keepalived_router_id: "42"
|
||||
keepalived_priority: "{% if keepalived_role == 'master' %}100{% else %}50{% endif %}"
|
||||
keepalived_ip: ""
|
||||
keepalived_password: ""
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: restart keepalived
|
||||
systemd:
|
||||
name: keepalived
|
||||
state: restarted
|
|
@ -0,0 +1,18 @@
|
|||
- name: install Keepalived service
|
||||
apt:
|
||||
pkg: keepalived
|
||||
state: present
|
||||
|
||||
- name: generate Keepalived configuration
|
||||
template:
|
||||
src: keepalived.conf.j2
|
||||
dest: /etc/keepalived/keepalived.conf
|
||||
mode: 0644
|
||||
notify: restart keepalived
|
||||
|
||||
- name: enable and restart Keepalived service
|
||||
systemd:
|
||||
name: keepalived
|
||||
daemon_reload: yes
|
||||
state: started
|
||||
enabled: yes
|
|
@ -0,0 +1,29 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
vrrp_script chk_sshd {
|
||||
script "/usr/bin/pkill -0 sshd"
|
||||
interval 5
|
||||
weight -4
|
||||
fall 2
|
||||
rise 1
|
||||
}
|
||||
|
||||
vrrp_instance vrrp {
|
||||
interface {{ keepalived_interface | mandatory }}
|
||||
virtual_router_id {{ keepalived_router_id | mandatory }}
|
||||
state {{ keepalived_role | upper }}
|
||||
priority {{ keepalived_priority }}
|
||||
|
||||
virtual_ipaddress {
|
||||
{{ keepalived_ip | mandatory }}
|
||||
}
|
||||
|
||||
authentication {
|
||||
auth_type PASS
|
||||
auth_pass {{ keepalived_password | mandatory }}
|
||||
}
|
||||
|
||||
track_script {
|
||||
chk_sshd
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue