cpe-deployments/scripts/arif-scripts/update_landscape_certs_self.sh

40 lines
1.4 KiB
Bash
Raw Normal View History

2021-10-29 09:57:19 +01:00
#!/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)
2021-10-29 09:57:19 +01:00
# 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)
2021-10-29 09:57:19 +01:00
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.example.com/message-system" \
ping-url="http://landscape.example.com/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.example.com/message-system" \
ping-url="http://landscape.example.com/ping"
juju run -m ${model} -a ${client} 'sudo systemctl restart landscape-client.service'
done