From 4b84e17f830ef6e5323bbe982a040f3290189843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kub=C3=ADn?= Date: Thu, 15 Mar 2018 16:30:58 +0000 Subject: [PATCH 1/2] Adding conditional processing of swift auth parameters These changes should patch an issue observed in Ocata when Swift is set as Glance backend with *references* method of auth sections addressing. While `glance-api.conf` template is set to check for swift auth parameters definition, `glance-glare.conf` is not which makes salt-formula-glance fail during execution. --- glance/files/newton/glance-glare.conf.Debian | 16 ++++++++++++++-- glance/files/ocata/glance-glare.conf.Debian | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/glance/files/newton/glance-glare.conf.Debian b/glance/files/newton/glance-glare.conf.Debian index fa9bf02..3022946 100644 --- a/glance/files/newton/glance-glare.conf.Debian +++ b/glance/files/newton/glance-glare.conf.Debian @@ -1361,7 +1361,9 @@ rbd_store_ceph_conf = /etc/ceph/ceph.conf {%- if 'swift' in storage_engines %} #swift_store_auth_insecure = false +{% if server.storage.swift.store.get('auth', {}).get('insecure', False) %} swift_store_auth_insecure = {{ server.storage.swift.store.auth.get('insecure', False)|lower }} +{% endif %} # # Path to the CA bundle file. @@ -1809,7 +1811,10 @@ default_swift_reference = {{ server.storage.swift.store.default_swift_reference # The option 'auth_version' in the Swift back-end configuration file is # used instead. #swift_store_auth_version = 2 + +{% if server.storage.swift.store.get('auth', {}).get('version', False) %} swift_store_auth_version = {{ server.storage.swift.store.auth.version }} +{% endif %} # DEPRECATED: The address where the Swift authentication service is listening. # (string value) @@ -1819,7 +1824,10 @@ swift_store_auth_version = {{ server.storage.swift.store.auth.version }} # The option 'auth_address' in the Swift back-end configuration file is # used instead. #swift_store_auth_address = + +{% if server.storage.swift.store.get('auth', {}).get('address', False) %} swift_store_auth_address = {{ server.storage.swift.store.auth.address }} +{% endif %} # DEPRECATED: The user to authenticate against the Swift authentication service. # (string value) @@ -1828,7 +1836,9 @@ swift_store_auth_address = {{ server.storage.swift.store.auth.address }} # Reason: # The option 'user' in the Swift back-end configuration file is set instead. #swift_store_user = +{% if server.storage.swift.store.get('user', False) %} swift_store_user = {{ server.storage.swift.store.user }} +{% endif %} # DEPRECATED: Auth key for the user authenticating against the Swift # authentication service. (string value) @@ -1838,7 +1848,9 @@ swift_store_user = {{ server.storage.swift.store.user }} # The option 'key' in the Swift back-end configuration file is used # to set the authentication key instead. #swift_store_key = +{% if server.storage.swift.store.get('key', False) %} swift_store_key = {{ server.storage.swift.store.key }} +{% endif %} # # Absolute path to the file containing the swift account(s) @@ -1860,8 +1872,8 @@ swift_store_key = {{ server.storage.swift.store.key }} # # (string value) #swift_store_config_file = -{% if server.storage.swift.store.config_file is defined %} -swift_store_config_file = {{ server.storage.swift.store.config_file }} +{% if server.storage.swift.store.references is defined %} +swift_store_config_file = /etc/glance/swift-stores.conf {% endif %} {% endif %} diff --git a/glance/files/ocata/glance-glare.conf.Debian b/glance/files/ocata/glance-glare.conf.Debian index c9e79d6..1bedd99 100644 --- a/glance/files/ocata/glance-glare.conf.Debian +++ b/glance/files/ocata/glance-glare.conf.Debian @@ -1363,7 +1363,9 @@ rbd_store_ceph_conf = /etc/ceph/ceph.conf {%- if 'swift' in storage_engines %} #swift_store_auth_insecure = false +{% if server.storage.swift.store.get('auth', {}).get('insecure', False) %} swift_store_auth_insecure = {{ server.storage.swift.store.auth.get('insecure', False)|lower }} +{% endif %} # # Path to the CA bundle file. @@ -1811,7 +1813,10 @@ default_swift_reference = {{ server.storage.swift.store.default_swift_reference # The option 'auth_version' in the Swift back-end configuration file is # used instead. #swift_store_auth_version = 2 + +{% if server.storage.swift.store.get('auth', {}).get('version', False) %} swift_store_auth_version = {{ server.storage.swift.store.auth.version }} +{% endif %} # DEPRECATED: The address where the Swift authentication service is listening. # (string value) @@ -1821,7 +1826,10 @@ swift_store_auth_version = {{ server.storage.swift.store.auth.version }} # The option 'auth_address' in the Swift back-end configuration file is # used instead. #swift_store_auth_address = + +{% if server.storage.swift.store.get('auth', {}).get('address', False) %} swift_store_auth_address = {{ server.storage.swift.store.auth.address }} +{% endif %} # DEPRECATED: The user to authenticate against the Swift authentication service. # (string value) @@ -1830,7 +1838,9 @@ swift_store_auth_address = {{ server.storage.swift.store.auth.address }} # Reason: # The option 'user' in the Swift back-end configuration file is set instead. #swift_store_user = +{% if server.storage.swift.store.get('user', False) %} swift_store_user = {{ server.storage.swift.store.user }} +{% endif %} # DEPRECATED: Auth key for the user authenticating against the Swift # authentication service. (string value) @@ -1840,7 +1850,9 @@ swift_store_user = {{ server.storage.swift.store.user }} # The option 'key' in the Swift back-end configuration file is used # to set the authentication key instead. #swift_store_key = +{% if server.storage.swift.store.get('key', False) %} swift_store_key = {{ server.storage.swift.store.key }} +{% endif %} # # Absolute path to the file containing the swift account(s) @@ -1862,8 +1874,8 @@ swift_store_key = {{ server.storage.swift.store.key }} # # (string value) #swift_store_config_file = -{% if server.storage.swift.store.config_file is defined %} -swift_store_config_file = {{ server.storage.swift.store.config_file }} +{% if server.storage.swift.store.references is defined %} +swift_store_config_file = /etc/glance/swift-stores.conf {% endif %} {% endif %} From a1ed5677d845b625db565397f59d98b17ce78a63 Mon Sep 17 00:00:00 2001 From: Lukas Kubin Date: Fri, 16 Mar 2018 18:25:10 +0100 Subject: [PATCH 2/2] Whitespace handling --- glance/files/newton/glance-glare.conf.Debian | 12 +++++------- glance/files/ocata/glance-glare.conf.Debian | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/glance/files/newton/glance-glare.conf.Debian b/glance/files/newton/glance-glare.conf.Debian index 3022946..b1c2d47 100644 --- a/glance/files/newton/glance-glare.conf.Debian +++ b/glance/files/newton/glance-glare.conf.Debian @@ -1361,7 +1361,7 @@ rbd_store_ceph_conf = /etc/ceph/ceph.conf {%- if 'swift' in storage_engines %} #swift_store_auth_insecure = false -{% if server.storage.swift.store.get('auth', {}).get('insecure', False) %} +{%- if server.storage.swift.store.get('auth', {}).get('insecure', False) %} swift_store_auth_insecure = {{ server.storage.swift.store.auth.get('insecure', False)|lower }} {% endif %} @@ -1811,8 +1811,7 @@ default_swift_reference = {{ server.storage.swift.store.default_swift_reference # The option 'auth_version' in the Swift back-end configuration file is # used instead. #swift_store_auth_version = 2 - -{% if server.storage.swift.store.get('auth', {}).get('version', False) %} +{%- if server.storage.swift.store.get('auth', {}).get('version', False) %} swift_store_auth_version = {{ server.storage.swift.store.auth.version }} {% endif %} @@ -1824,8 +1823,7 @@ swift_store_auth_version = {{ server.storage.swift.store.auth.version }} # The option 'auth_address' in the Swift back-end configuration file is # used instead. #swift_store_auth_address = - -{% if server.storage.swift.store.get('auth', {}).get('address', False) %} +{%- if server.storage.swift.store.get('auth', {}).get('address', False) %} swift_store_auth_address = {{ server.storage.swift.store.auth.address }} {% endif %} @@ -1836,7 +1834,7 @@ swift_store_auth_address = {{ server.storage.swift.store.auth.address }} # Reason: # The option 'user' in the Swift back-end configuration file is set instead. #swift_store_user = -{% if server.storage.swift.store.get('user', False) %} +{%- if server.storage.swift.store.get('user', False) %} swift_store_user = {{ server.storage.swift.store.user }} {% endif %} @@ -1848,7 +1846,7 @@ swift_store_user = {{ server.storage.swift.store.user }} # The option 'key' in the Swift back-end configuration file is used # to set the authentication key instead. #swift_store_key = -{% if server.storage.swift.store.get('key', False) %} +{%- if server.storage.swift.store.get('key', False) %} swift_store_key = {{ server.storage.swift.store.key }} {% endif %} diff --git a/glance/files/ocata/glance-glare.conf.Debian b/glance/files/ocata/glance-glare.conf.Debian index 1bedd99..66cf7cb 100644 --- a/glance/files/ocata/glance-glare.conf.Debian +++ b/glance/files/ocata/glance-glare.conf.Debian @@ -1363,7 +1363,7 @@ rbd_store_ceph_conf = /etc/ceph/ceph.conf {%- if 'swift' in storage_engines %} #swift_store_auth_insecure = false -{% if server.storage.swift.store.get('auth', {}).get('insecure', False) %} +{%- if server.storage.swift.store.get('auth', {}).get('insecure', False) %} swift_store_auth_insecure = {{ server.storage.swift.store.auth.get('insecure', False)|lower }} {% endif %} @@ -1813,8 +1813,7 @@ default_swift_reference = {{ server.storage.swift.store.default_swift_reference # The option 'auth_version' in the Swift back-end configuration file is # used instead. #swift_store_auth_version = 2 - -{% if server.storage.swift.store.get('auth', {}).get('version', False) %} +{%- if server.storage.swift.store.get('auth', {}).get('version', False) %} swift_store_auth_version = {{ server.storage.swift.store.auth.version }} {% endif %} @@ -1826,8 +1825,7 @@ swift_store_auth_version = {{ server.storage.swift.store.auth.version }} # The option 'auth_address' in the Swift back-end configuration file is # used instead. #swift_store_auth_address = - -{% if server.storage.swift.store.get('auth', {}).get('address', False) %} +{%- if server.storage.swift.store.get('auth', {}).get('address', False) %} swift_store_auth_address = {{ server.storage.swift.store.auth.address }} {% endif %} @@ -1838,7 +1836,7 @@ swift_store_auth_address = {{ server.storage.swift.store.auth.address }} # Reason: # The option 'user' in the Swift back-end configuration file is set instead. #swift_store_user = -{% if server.storage.swift.store.get('user', False) %} +{%- if server.storage.swift.store.get('user', False) %} swift_store_user = {{ server.storage.swift.store.user }} {% endif %} @@ -1850,7 +1848,7 @@ swift_store_user = {{ server.storage.swift.store.user }} # The option 'key' in the Swift back-end configuration file is used # to set the authentication key instead. #swift_store_key = -{% if server.storage.swift.store.get('key', False) %} +{%- if server.storage.swift.store.get('key', False) %} swift_store_key = {{ server.storage.swift.store.key }} {% endif %}