network: Add keepalived support
This commit is contained in:
parent
a1d4d732ba
commit
d187472f27
3 changed files with 48 additions and 0 deletions
|
@ -7,4 +7,8 @@
|
||||||
- block:
|
- block:
|
||||||
- name: reload network manager connections
|
- name: reload network manager connections
|
||||||
command: nmcli c reload
|
command: nmcli c reload
|
||||||
|
- name: restart keepalived
|
||||||
|
service:
|
||||||
|
name: keepalived
|
||||||
|
state: restarted
|
||||||
when: ansible_os_family == "RedHat"
|
when: ansible_os_family == "RedHat"
|
||||||
|
|
|
@ -15,3 +15,25 @@
|
||||||
group: "{{ ansible_wheel }}"
|
group: "{{ ansible_wheel }}"
|
||||||
notify: reload network manager connections
|
notify: reload network manager connections
|
||||||
with_items: "{{ network_interfaces }}"
|
with_items: "{{ network_interfaces }}"
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: install keepalived
|
||||||
|
package:
|
||||||
|
name: keepalived
|
||||||
|
state: installed
|
||||||
|
- name: create keepalived config
|
||||||
|
template:
|
||||||
|
dest: /etc/keepalived/keepalived.conf
|
||||||
|
src: keepalived.conf.j2
|
||||||
|
mode: 0600
|
||||||
|
owner: root
|
||||||
|
group: "{{ ansible_wheel }}"
|
||||||
|
notify: restart keepalived
|
||||||
|
- name: enable keepalived
|
||||||
|
service:
|
||||||
|
name: keepalived
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
when:
|
||||||
|
- network_vip_interfaces is defined
|
||||||
|
- network_vip_interfaces != []
|
||||||
|
|
22
roles/network/templates/keepalived.conf.j2
Normal file
22
roles/network/templates/keepalived.conf.j2
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
! {{ ansible_managed }}
|
||||||
|
|
||||||
|
global_defs {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{% for vip in network_vip_interfaces %}
|
||||||
|
vrrp_instance VI_{{ vip.vhid }} {
|
||||||
|
interface {{ vip.device }}
|
||||||
|
virtual_router_id {{ vip.vhid }}
|
||||||
|
{% if vip.priority is defined %}
|
||||||
|
priority {{ vip.priority }}
|
||||||
|
{% endif %}
|
||||||
|
authentication {
|
||||||
|
auth_type AH
|
||||||
|
auth_pass {{ vip.pass }}
|
||||||
|
}
|
||||||
|
virtual_ipaddress {
|
||||||
|
{{ vip.ipaddr }}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{% endfor %}
|
Loading…
Add table
Add a link
Reference in a new issue