forked from ISTI-ansible-roles/ansible-roles
Merge branch 'master' of adellam/ansible-roles into master
This commit is contained in:
commit
eda7199cde
|
@ -21,6 +21,9 @@ keepalived_script1_name: keepalived_check_service_status
|
||||||
# We set haproxy as the default because most of our keepalived use is haproxy related
|
# We set haproxy as the default because most of our keepalived use is haproxy related
|
||||||
keepalived_service_to_check: 'haproxy'
|
keepalived_service_to_check: 'haproxy'
|
||||||
keepalived_script1_check: '/bin/pidof {{ keepalived_service_to_check }}'
|
keepalived_script1_check: '/bin/pidof {{ keepalived_service_to_check }}'
|
||||||
|
keepalived_instance1_name: 'VRRP_1'
|
||||||
|
keepalived_interface1_name: '{{ ansible_default_ipv4.interface }}'
|
||||||
|
keepalived_initial_state: 'MASTER'
|
||||||
keepalived_inst_priority: 100
|
keepalived_inst_priority: 100
|
||||||
keepalived_vrouter_id: 51
|
keepalived_vrouter_id: 51
|
||||||
keepalived_non_local_bind: True
|
keepalived_non_local_bind: True
|
||||||
|
@ -28,6 +31,7 @@ keepalived_non_local_bind: True
|
||||||
keepalived_enable_script_security: True
|
keepalived_enable_script_security: True
|
||||||
keepalived_script_username: keepalived_script
|
keepalived_script_username: keepalived_script
|
||||||
keepalived_script_user_home: '/var/lib/keepalived'
|
keepalived_script_user_home: '/var/lib/keepalived'
|
||||||
|
keepalived_runtime_dir: /run/keepalived
|
||||||
|
|
||||||
keepalived_nagios_check: False
|
keepalived_nagios_check: False
|
||||||
keepalived_notify_script: /usr/local/bin/keepalived_notify
|
keepalived_notify_script: /usr/local/bin/keepalived_notify
|
||||||
|
@ -43,15 +47,16 @@ keepalived_scripts:
|
||||||
weight: 2
|
weight: 2
|
||||||
|
|
||||||
keepalived_instances:
|
keepalived_instances:
|
||||||
- name: VI_1
|
- name: '{{ keepalived_instance1_name }}'
|
||||||
interface: eth0
|
interface: '{{ keepalived_interface1_name }}'
|
||||||
state: MASTER
|
state: '{{ keepalived_initial_state }}'
|
||||||
vrouter_id: '{{ keepalived_vrouter_id }}'
|
vrouter_id: '{{ keepalived_vrouter_id }}'
|
||||||
notify: '{{ keepalived_notify_script }}'
|
notify: '{{ keepalived_notify_script }}'
|
||||||
priority: '{{ keepalived_inst_priority }}'
|
priority: '{{ keepalived_inst_priority }}'
|
||||||
|
nopreempt: True
|
||||||
v_addr:
|
v_addr:
|
||||||
- '{{ keepalived_floating_ip1 }}'
|
- '{{ keepalived_floating_ip1 }}'
|
||||||
track_script:
|
track_script:
|
||||||
- '{{ keepalived_script1_name }}'
|
- '{{ keepalived_script1_name }}'
|
||||||
#track_interface:
|
track_interface:
|
||||||
# - eth0
|
- '{{ keepalived_interface1_name }}'
|
||||||
|
|
|
@ -7,18 +7,22 @@
|
||||||
- name: Install the keepalived package
|
- name: Install the keepalived package
|
||||||
apt: name={{ keepalived_pkgs }} state={{ keepalived_pkg_state }} cache_valid_time=1800
|
apt: name={{ keepalived_pkgs }} state={{ keepalived_pkg_state }} cache_valid_time=1800
|
||||||
|
|
||||||
- name: Install the user that the keepalived scripts will run under
|
|
||||||
user: name={{ keepalived_script_username }} home={{ keepalived_script_user_home }} createhome=no shell=/usr/sbin/nologin system=yes
|
|
||||||
|
|
||||||
tags: keepalived
|
tags: keepalived
|
||||||
when:
|
when:
|
||||||
- keepalived_install | bool
|
- keepalived_install | bool
|
||||||
- ansible_distribution_file_variety == "Debian"
|
- ansible_distribution_file_variety == "Debian"
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
- name: Install the user that the keepalived scripts will run under
|
||||||
|
user: name={{ keepalived_script_username }} home={{ keepalived_script_user_home }} createhome=no shell=/usr/sbin/nologin system=yes
|
||||||
|
|
||||||
- name: Create the keepalive script user directory
|
- name: Create the keepalive script user directory
|
||||||
file: dest={{ keepalived_script_user_home }} state=directory owner={{ keepalived_script_username }} group={{ keepalived_script_username }} mode=0750
|
file: dest={{ keepalived_script_user_home }} state=directory owner={{ keepalived_script_username }} group={{ keepalived_script_username }} mode=0750
|
||||||
|
|
||||||
|
- name: Create the tmpfile entry for the keepalived runtime directory
|
||||||
|
template: src=tmpfile_keepalived.conf.j2 dest=/usr/lib/tmpfiles.d/keepalived.conf owner=root group=root mode=0644
|
||||||
|
when: ansible_service_mgr == 'systemd'
|
||||||
|
|
||||||
- name: Install the keepalived configuration
|
- name: Install the keepalived configuration
|
||||||
template: src=keepalived.conf.j2 dest=/etc/keepalived/keepalived.conf owner=root group=root mode=0600
|
template: src=keepalived.conf.j2 dest=/etc/keepalived/keepalived.conf owner=root group=root mode=0600
|
||||||
notify: restart keepalived
|
notify: restart keepalived
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
{% if ansible_distribution_file_variety == "Debian" and ansible_distribution_major_version == '18' %}
|
{% if ansible_distribution_file_variety == "Debian" and ansible_distribution_major_version == '18' %}
|
||||||
am_i_master=$( grep MASTER /var/lib/keepalived/keepalive.state )
|
am_i_master=$( grep MASTER {{ keepalived_runtime_dir }}/keepalive.state )
|
||||||
keepalive_master=$?
|
keepalive_master=$?
|
||||||
|
|
||||||
if [ $keepalive_master -eq 0 ] ; then
|
if [ $keepalive_master -eq 0 ] ; then
|
||||||
|
|
|
@ -13,7 +13,7 @@ RETVAL=0
|
||||||
{{ keepalived_notify_extra_params }}
|
{{ keepalived_notify_extra_params }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
echo "$TYPE $NAME is in $STATE state" > {{ keepalived_script_user_home }}/keepalive.state
|
echo "$TYPE $NAME is in $STATE state" > {{ keepalived_runtime_dir }}/keepalive.state
|
||||||
|
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
d {{ keepalived_runtime_dir }} 0775 {{ keepalived_script_username }} {{ keepalived_script_username }}
|
Loading…
Reference in New Issue