cpe-deployments/scripts/arif-scripts/update_landscape_certs_self.sh
Arif Ali 5695de6e99
Some quick updates
* Updating to use -a instead of --application
* use -r for jq, and not use sed
2022-03-14 12:04:57 +00:00

24 lines
939 B
Bash
Executable File

#!/bin/bash
# This is when landscape-haproxy the cert is SELFSIGNED. This will ensure that landscape will work
landscape_crt=$(juju run --application landscape-haproxy 'sudo openssl x509 -in /var/lib/haproxy/default.pem' | base64)
# 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