Merge branch 'master' of adellam/ansible-roles into master

This commit is contained in:
Andrea Dell'Amico 2020-02-14 18:39:51 +01:00 committed by Gitea
commit eda7199cde
5 changed files with 20 additions and 10 deletions

View File

@ -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
keepalived_service_to_check: 'haproxy'
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_vrouter_id: 51
keepalived_non_local_bind: True
@ -28,6 +31,7 @@ keepalived_non_local_bind: True
keepalived_enable_script_security: True
keepalived_script_username: keepalived_script
keepalived_script_user_home: '/var/lib/keepalived'
keepalived_runtime_dir: /run/keepalived
keepalived_nagios_check: False
keepalived_notify_script: /usr/local/bin/keepalived_notify
@ -43,15 +47,16 @@ keepalived_scripts:
weight: 2
keepalived_instances:
- name: VI_1
interface: eth0
state: MASTER
- name: '{{ keepalived_instance1_name }}'
interface: '{{ keepalived_interface1_name }}'
state: '{{ keepalived_initial_state }}'
vrouter_id: '{{ keepalived_vrouter_id }}'
notify: '{{ keepalived_notify_script }}'
priority: '{{ keepalived_inst_priority }}'
nopreempt: True
v_addr:
- '{{ keepalived_floating_ip1 }}'
track_script:
- '{{ keepalived_script1_name }}'
#track_interface:
# - eth0
track_interface:
- '{{ keepalived_interface1_name }}'

View File

@ -7,18 +7,22 @@
- name: Install the keepalived package
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
when:
- keepalived_install | bool
- ansible_distribution_file_variety == "Debian"
- 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
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
template: src=keepalived.conf.j2 dest=/etc/keepalived/keepalived.conf owner=root group=root mode=0600
notify: restart keepalived

View File

@ -1,6 +1,6 @@
#!/bin/bash
{% 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=$?
if [ $keepalive_master -eq 0 ] ; then

View File

@ -13,7 +13,7 @@ RETVAL=0
{{ keepalived_notify_extra_params }}
{% 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

View File

@ -0,0 +1 @@
d {{ keepalived_runtime_dir }} 0775 {{ keepalived_script_username }} {{ keepalived_script_username }}