From d57c7019a92f498f8dd876f4daea9051801f856c Mon Sep 17 00:00:00 2001 From: jiangpch Date: Mon, 9 Oct 2017 02:47:05 -0400 Subject: [PATCH] Make haproxy proxy to the right glance_api backend Since glance_api only start one container when using file backend, the haproxy should follow this rule. See: https://review.openstack.org/#/c/448654 Closes-Bug: #1722422 Change-Id: Id3519581e0f54509dacd24d0dd542c630342c771 --- ansible/group_vars/all.yml | 1 + ansible/roles/glance/defaults/main.yml | 2 -- ansible/roles/haproxy/templates/haproxy.cfg.j2 | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 453c05f776..7a3112af87 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -640,6 +640,7 @@ glance_backend_vmware: "no" glance_backend_swift: "{{ not (enable_ceph | bool) and enable_swift | bool }}" glance_file_datadir_volume: "glance" glance_enable_rolling_upgrade: "no" +glance_api_hosts: "{{ [groups['glance-api']|first] if glance_backend_file | bool and glance_file_datadir_volume == 'glance' else groups['glance-api'] }}" ####################### # Barbican options diff --git a/ansible/roles/glance/defaults/main.yml b/ansible/roles/glance/defaults/main.yml index d4b401fdd8..6c9f493fa0 100644 --- a/ansible/roles/glance/defaults/main.yml +++ b/ansible/roles/glance/defaults/main.yml @@ -103,8 +103,6 @@ glance_backends: glance_store_backends: "{{ glance_backends|selectattr('enabled', 'equalto', true)|list }}" -glance_api_hosts: "{{ groups['glance-api']|first if glance_backend_file | bool and glance_file_datadir_volume == 'glance' else groups['glance-api'] }}" - #################### # OpenStack #################### diff --git a/ansible/roles/haproxy/templates/haproxy.cfg.j2 b/ansible/roles/haproxy/templates/haproxy.cfg.j2 index 4d87acde80..09dfc530fe 100644 --- a/ansible/roles/haproxy/templates/haproxy.cfg.j2 +++ b/ansible/roles/haproxy/templates/haproxy.cfg.j2 @@ -144,7 +144,7 @@ listen glance_api {% for http_option in haproxy_listen_http_extra %} {{ http_option }} {% endfor %} -{% for host in groups['glance-api'] %} +{% for host in glance_api_hosts %} server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ glance_api_port }} check inter 2000 rise 2 fall 5 {% endfor %} {% if haproxy_enable_external_vip | bool %} @@ -158,7 +158,7 @@ listen glance_api_external {% endfor %} http-request del-header X-Forwarded-Proto http-request set-header X-Forwarded-Proto https if { ssl_fc } -{% for host in groups['glance-api'] %} +{% for host in glance_api_hosts %} server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ glance_api_port }} check inter 2000 rise 2 fall 5 {% endfor %} {% endif %}