diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 208b8c7974..fa8159981f 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -639,6 +639,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 %}