From d34b9f512f32a7611d8a32c796e8b2130fd39cfb Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 30 Sep 2020 19:02:46 +0200 Subject: [PATCH] keepalived configuration added --- defaults/main.yml | 3 +++ vars/main.yml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index 2fee16d..9be0704 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -20,3 +20,6 @@ docker_swarm_portainer_service_port: '8000' docker_swarm_haproxy_additional_services: [] # - { acl_name: 'service', acl_rule: 'hdr_dom(host) -i service.example.com', service_name: 'service-', service_replica_num: '1', service_port: '9999', service_overlay_network: 'service-network' } +docker_swarm_keepalived_vrouter_id: 205 +docker_swarm_keepalived_floating_ip: '127.0.0.1/8' +docker_swarm_keepalived_instance_name: 'VI_HAPROXY_1' diff --git a/vars/main.yml b/vars/main.yml index 321cd90..d2328cd 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -2,3 +2,39 @@ haproxy_docker_container: True haproxy_docker_compose_dir: /src/haproxy_swarm haproxy_ha_with_keepalived: True + +keepalived_install: True +keepalived_vrouter_id: '{{ docker_swarm_keepalived_vrouter_id }}' +keepalived_use_unicast: False +keepalived_floating_ip1: '{{ docker_swarm_keepalived_floating_ip }}' +keepalived_instance1_name: '{{ docker_swarm_keepalived_instance_name }}' +keepalived_nagios_check: False +keepalived_service_to_check: 'haproxy' +keepalived_script1_check: "/usr/bin/docker container ls --filter name=haproxy | /bin/grep haproxy" + +keepalived_scripts: + - name: '{{ keepalived_script1_name }}' + script: '{{ keepalived_check_script }}' + # In seconds + interval: 2 + # Priority increment + weight: -20 + fall: 2 + raise: 2 + +keepalived_instances: + - name: '{{ keepalived_instance1_name }}' + interface: '{{ ansible_default_ipv4.interface }}' + state: BACKUP + 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: + - '{{ ansible_default_ipv4.interface }}' + authentication: PASS + authpass: '{{ keepass_auth_pwd }}'