Merge ~hopem/stsstack-bundles:ensure-local-ca-installed-per-model into stsstack-bundles:master

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 5c9f46f641f45ff557f531b537257d093b2c07b2
Proposed branch: ~hopem/stsstack-bundles:ensure-local-ca-installed-per-model
Merge into: stsstack-bundles:master
Diff against target: 88 lines (+25/-15)
5 files modified
ceph/tools/install_local_ca.sh (+1/-0)
kubernetes/tools/install_local_ca.sh (+1/-0)
openstack/novarc (+13/-5)
openstack/tools/install_local_ca.sh (+9/-10)
swift/tools/install_local_ca.sh (+1/-0)
Reviewer Review Type Date Requested Status
Jolly Bundlers Pending
Review via email: mp+390970@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ceph/tools/install_local_ca.sh b/ceph/tools/install_local_ca.sh
2new file mode 120000
3index 0000000..90d5dfd
4--- /dev/null
5+++ b/ceph/tools/install_local_ca.sh
6@@ -0,0 +1 @@
7+../../openstack/tools/install_local_ca.sh
8\ No newline at end of file
9diff --git a/kubernetes/tools/install_local_ca.sh b/kubernetes/tools/install_local_ca.sh
10new file mode 120000
11index 0000000..90d5dfd
12--- /dev/null
13+++ b/kubernetes/tools/install_local_ca.sh
14@@ -0,0 +1 @@
15+../../openstack/tools/install_local_ca.sh
16\ No newline at end of file
17diff --git a/openstack/novarc b/openstack/novarc
18index 96ebcf6..252cc22 100644
19--- a/openstack/novarc
20+++ b/openstack/novarc
21@@ -20,14 +20,22 @@ fi
22 ssl_cert=`juju config keystone ssl_cert`
23 if [ -n "$ssl_cert" ]; then
24 export OS_AUTH_PROTOCOL=https
25+ # NOTE(hopem): we don't actually need OS_CACERT if the cert is installed and that should be fixed now
26+ # so we could consider removing this.
27 export OS_CACERT=$(dirname "$(realpath -s "${BASH_SOURCE[0]}")")/ssl/openstack-ssl/results/cacert.pem
28-else
29+elif ((`jq -r '.applications[]| select(."charm-name"=="vault")' $juju_status_json_cache| wc -l`)); then
30 # Vault-based ssl
31- if ((`jq -r '.applications[]| select(."charm-name"=="vault")' $juju_status_json_cache| wc -l`)); then
32- if `jq -r .applications.vault.relations.certificates[] $juju_status_json_cache| grep -q keystone`; then
33- export OS_AUTH_PROTOCOL=https
34- fi
35+ if `jq -r .applications.vault.relations.certificates[] $juju_status_json_cache| grep -q keystone`; then
36+ export OS_AUTH_PROTOCOL=https
37 fi
38+else
39+ unset OS_AUTH_PROTOCOL
40+fi
41+
42+if [ "${OS_AUTH_PROTOCOL:-}" = "https" ]; then
43+ echo -n "INFO: installing certificate authority for this deployment..."
44+ ./tools/install_local_ca.sh &>/dev/null
45+ echo done.
46 fi
47
48 unset _OS_PARAMS
49diff --git a/openstack/tools/install_local_ca.sh b/openstack/tools/install_local_ca.sh
50index e6770ff..a72d510 100755
51--- a/openstack/tools/install_local_ca.sh
52+++ b/openstack/tools/install_local_ca.sh
53@@ -1,18 +1,17 @@
54 #!/bin/bash -eux
55-local_ca_crt_path=${1:-ssl/openstack/results/cacert.pem}
56-
57-ftmp=`mktemp`
58-
59-cleanup () { rm -f $ftmp; }
60-trap cleanup EXIT INT
61+model_ca_cert_path=${1:-ssl/openstack/results/cacert.pem}
62
63 if ((`juju status --format=json| jq -r '.applications[]| select(."charm-name"=="vault")'| wc -l`)); then
64- echo "Fetching CA cert from vault"
65- juju run-action --format=json vault/leader get-root-ca --wait | jq -r .[].results.output > $ftmp
66- local_ca_crt_path=$ftmp
67+ model_uuid=`juju show-model --format=json| jq -r '.[]."model-uuid"'`
68+ model_ca_cert_path=`find /tmp -name \*.stsstack-bundles.ssl.$model_uuid 2>/dev/null` || true
69+ if [ -z "$model_ca_cert_path" ]; then
70+ model_ca_cert_path=`mktemp --suffix=.stsstack-bundles.ssl.$model_uuid`
71+ echo "Fetching CA cert from vault"
72+ juju run-action --format=json vault/leader get-root-ca --wait | jq -r .[].results.output > $model_ca_cert_path
73+ fi
74 fi
75
76 echo "INFO: installing stsstack-bundles openstack CA at /usr/local/share/ca-certificates/cacert.crt"
77-sudo cp ${local_ca_crt_path} /usr/local/share/ca-certificates/cacert.crt
78+sudo cp ${model_ca_cert_path} /usr/local/share/ca-certificates/cacert.crt
79 sudo chmod 644 /usr/local/share/ca-certificates/cacert.crt
80 sudo update-ca-certificates --fresh
81diff --git a/swift/tools/install_local_ca.sh b/swift/tools/install_local_ca.sh
82new file mode 120000
83index 0000000..90d5dfd
84--- /dev/null
85+++ b/swift/tools/install_local_ca.sh
86@@ -0,0 +1 @@
87+../../openstack/tools/install_local_ca.sh
88\ No newline at end of file

Subscribers

People subscribed via source and target branches