From 43058477e4105aa9d1b8e3ff285b7c57a62b4f1e Mon Sep 17 00:00:00 2001 From: tonytan4ever Date: Wed, 5 Dec 2018 16:08:49 -0500 Subject: [PATCH] Autoload OS_CACERT environment variable --- inventory/rpcr_dynamic_inventory.py | 12 ++++++++++++ ...auto-load-OS_CACERT-env-var-ae25fc79f62663ba.yaml | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 releasenotes/notes/auto-load-OS_CACERT-env-var-ae25fc79f62663ba.yaml diff --git a/inventory/rpcr_dynamic_inventory.py b/inventory/rpcr_dynamic_inventory.py index 72d89dfef..4753d6ded 100755 --- a/inventory/rpcr_dynamic_inventory.py +++ b/inventory/rpcr_dynamic_inventory.py @@ -43,6 +43,7 @@ class RPCRMaasInventory(MaasInventory): def __init__(self): # Load stackrc environment variable file self.load_stackrc_file() + self.load_os_cacert() super(RPCRMaasInventory, self).__init__() def read_input_inventory(self): @@ -91,6 +92,17 @@ def load_stackrc_file(self): v = match.group('value').strip('"').strip("'") os.environ[k] = v + def load_os_cacert(self): + os_cert_path = '/etc/pki/ca-trust/source/anchors/' + if os.path.exists(os_cert_path): + # load the cert file in this directory + certs = [] + for f in os.listdir(os_cert_path): + f_path = os.path.join(os_cert_path, f) + if os.path.isfile(f_path): + certs.append(f_path) + os.environ['OS_CACERT'] = ' '.join(certs) + def get_tripleo_plan_name(self): oss_command = 'stack list -f json' stack_list_result = self.run_oss_command(oss_command) diff --git a/releasenotes/notes/auto-load-OS_CACERT-env-var-ae25fc79f62663ba.yaml b/releasenotes/notes/auto-load-OS_CACERT-env-var-ae25fc79f62663ba.yaml new file mode 100644 index 000000000..166eedd34 --- /dev/null +++ b/releasenotes/notes/auto-load-OS_CACERT-env-var-ae25fc79f62663ba.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + The rpcr-dynamic inventory now is able to set OS_CACERT environment + variable automatically. +upgrade: + - | + Deployment process can skip the step setting OS_CACERT. \ No newline at end of file