From 8bfb7897903a495a98a6aa59ae1149964e9c0e20 Mon Sep 17 00:00:00 2001
From: Vladislav Belogrudov <vladislav.belogrudov@oracle.com>
Date: Fri, 11 May 2018 18:01:15 +0300
Subject: [PATCH] Fix default value logic of 'glance_backend_file' variable

glance_backend_file should be set to 'yes' if no other backends
are enabled. In all-Ceph clusters the best choice of backend is
Ceph. In non-Ceph clusters if Swift is enabled the latter is the
next best choice for Glance. With this fix default backend is
configured automatically and helps avoid non-ha file backend
issues after deployment.

Change-Id: I3d1c7cb2de9fedecdf9ad8744f6589c6f3f83ece
Closes-Bug: #1770660
---
 ansible/group_vars/all.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml
index 5d774a8a3d..3a3a2bc464 100644
--- a/ansible/group_vars/all.yml
+++ b/ansible/group_vars/all.yml
@@ -586,10 +586,11 @@ keystone_default_user_role: "_member_"
 # Using glance_backend_ceph rather than enable_ceph to determine whether to
 # use the file backend, as this allows for the external ceph case, where
 # enable_ceph is False.
-glance_backend_file: "{{ not glance_backend_ceph | bool }}"
+glance_backend_file: "{{ not (glance_backend_ceph | bool or glance_backend_swift | bool or glance_backend_vmware | bool) }}"
 glance_backend_ceph: "{{ enable_ceph }}"
 glance_backend_vmware: "no"
-glance_backend_swift: "no"
+# ceph backend has priority over swift in all-ceph clusters
+glance_backend_swift: "{{ not (enable_ceph | bool) and enable_swift | bool }}"
 glance_file_datadir_volume: "glance"
 glance_enable_rolling_upgrade: "no"