cpe-deployments/scripts/arif-scripts/update_landscape_certs_self.sh
Arif Ali 40ce5b3395
Add controller model LMA + extras
* Test initial LMA stuff for controller model
* Add a script to add tags in Landscape based on juju AZs
* Sync certs and update landscape-client config on all units
2022-03-17 19:09:11 +00:00

40 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# This is when landscape-haproxy the cert is SELFSIGNED. This will ensure that landscape will work
juju run --application landscape-haproxy 'sudo openssl x509 -in /var/lib/haproxy/default.pem' > landscape_cert.crt
landscape_crt=$(base64 < landscape_cert.crt)
# And yes, this needs to use the IP address, otherwise the the registration will fail
landscape_ip=$(juju run --application landscape-haproxy 'unit-get private-address')
juju_status=$(mktemp)
juju status --format json > "${juju_status}"
clients=$(jq -r ".applications | to_entries[] | select(.value[\"charm-name\"] == \"landscape-client\") | .key" "${juju_status}")
for client in ${clients} ; do
juju config ${client} --reset ssl-public-key,url,ping-url
juju config ${client} ssl-public-key="base64:${landscape_crt}" \
url="https://${landscape_ip}/message-system" \
ping-url="http://${landscape_ip}/ping"
juju run -a ${client} 'sudo systemctl restart landscape-client.service'
done
# for the infra model
models="infra controller"
client="landscape-client"
for model in ${models}
do
juju config -m ${model} ${client} --reset ssl-public-key,url,ping-url
juju config -m ${model} ${client} ssl-public-key="base64:${landscape_crt}" \
url="https://${landscape_ip}/message-system" \
ping-url="http://${landscape_ip}/ping"
juju run -m ${model} -a ${client} 'sudo systemctl restart landscape-client.service'
done