]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-rgw-loadbalancer: Modify keepalived master selection
authorStanley Lam <stanleylam_604@hotmail.com>
Tue, 3 Dec 2019 18:51:22 +0000 (10:51 -0800)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Mon, 6 Jan 2020 14:25:04 +0000 (09:25 -0500)
Currently the keepalived template only works when system hostnames exactly match the Ansible inventory name. If these are different, all generated templates become BACKUP without a MASTER assigned. Using the inventory_hostname in the template file resolves this issue.

Signed-off-by: Stanley Lam stanleylam_604@hotmail.com
roles/ceph-rgw-loadbalancer/tasks/pre_requisite.yml
roles/ceph-rgw-loadbalancer/templates/keepalived.conf.j2

index 7d3c33a872b13179a3b3a79bc7c5f36019740e9b..2772e41af7aa4f8a3977279821e97214f13b709f 100644 (file)
 
 - name: set_fact vip to vrrp_instance
   set_fact:
-      vrrp_instances: "{{ vrrp_instances | default([]) | union([{ 'name': 'VI_' + index|string , 'vip': item, 'master': groups[rgwloadbalancer_group_name][index] }]) }}"
+      vrrp_instances: "{{ vrrp_instances | default([]) | union([{ 'name': 'VI_' + index|string , 'vip': item }]) }}"
   loop: "{{ virtual_ips | flatten(levels=1) }}"
-  loop_control:
-      index_var: index
 
 - name: "generate keepalived: configuration file: keepalived.conf"
   template:
index 0c5bd6135114b3c4f0dd8cd18840a76b308bb7e6..8beb0d44cd00fcba64286b1a6e9b1f5d88c58840 100644 (file)
@@ -15,8 +15,8 @@ vrrp_script check_haproxy {
 
 {% for instance in vrrp_instances %}
 vrrp_instance {{ instance['name'] }} {
-    state {{ 'MASTER' if ansible_hostname == instance['master'] else 'BACKUP' }}
-    priority {{ '100' if ansible_hostname == instance['master'] else '90' }}
+    state {{ 'MASTER' if inventory_hostname == groups[rgwloadbalancer_group_name][0] else 'BACKUP' }}
+    priority {{ '100' if inventory_hostname == groups[rgwloadbalancer_group_name][0] else '90' }}
     interface {{ virtual_ip_interface }}
     virtual_router_id {{ 50 + loop.index }}
     advert_int 1