From: Benoît Knecht Date: Mon, 1 Jun 2020 15:09:18 +0000 (+0200) Subject: ceph-rgw-loadbalancer: Fix keepalived master selection X-Git-Tag: v4.0.55~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97066a1ebc5928992b79aad6e6ed90c3bfc0a1f7;p=ceph-ansible.git ceph-rgw-loadbalancer: Fix keepalived master selection While 2ca33641 fixed a bug in the way the `keepalived.conf.j2` template matched hostnames to set the VRRP `MASTER`/`BACKUP` states, it also introduced a regression in the case where `virtual_ips` is a list of more than one IP address. The previous behavior would result in each host in the `rgwloadbalancers` group to be `MASTER` for one of the `virtual_ips`, but the new behavior caused the first host to be `MASTER` for all the IP address in `virtual_ips`. This commit restores the original behavior. Signed-off-by: Benoît Knecht (cherry picked from commit 2bede4762efaf566a7da689dd1021ee66c0c94eb) --- diff --git a/roles/ceph-rgw-loadbalancer/templates/keepalived.conf.j2 b/roles/ceph-rgw-loadbalancer/templates/keepalived.conf.j2 index 8793680f8..0c9378d3b 100644 --- a/roles/ceph-rgw-loadbalancer/templates/keepalived.conf.j2 +++ b/roles/ceph-rgw-loadbalancer/templates/keepalived.conf.j2 @@ -15,8 +15,8 @@ vrrp_script check_haproxy { {% for instance in vrrp_instances %} vrrp_instance {{ instance['name'] }} { - state {{ 'MASTER' if ansible_facts['hostname'] == instance['master'] else 'BACKUP' }} - priority {{ '100' if ansible_facts['hostname'] == instance['master'] else '90' }} + state {{ 'MASTER' if inventory_hostname == instance['master'] else 'BACKUP' }} + priority {{ '100' if inventory_hostname == instance['master'] else '90' }} interface {{ virtual_ip_interface }} virtual_router_id {{ 50 + loop.index }} advert_int 1