I am writing an action to modify something which… is part of a charms config… namely a set of domain names
I have an action called add-domain
, via a .sh file… and I noticed that it appears I will need to pull down, parse, and run in a loop… over all the relation ids… an update to the configs variable
is there a more elegant way than this ?
#!/bin/bash
unit_num=$(echo $JUJU_UNIT_NAME | cut -d'/' -f 2)
new_domain=$(action-get new-domain)
juju-log -l 'WARNING' "(add-domain) Adding a new domain $new_domain"
status-set maintenance "setup a new domain $new_domain $(date +"%H:%M")"
OLD_CONFIG="$(config-get mahrio_config)"
juju-log -l 'WARNING' "(add-domain) OLD_CONFIG $OLD_CONFIG"
NEW_CONFIG="${OLD_CONFIG}
${new_domain}"
juju-log -l 'WARNING' "(add-domain) NEW_CONFIG $NEW_CONFIG"
list_of_relation_ids=$(relation-ids website)
if [ -z "$list_of_relation_ids" ]; then
juju-log -l 'WARNING' "list_of_relation_ids is empty"
status-set maintenance "(u) You need to relate this unit to a consumer of website $(date +"%H:%M")"
exit
fi
juju-log -l 'WARNING' "list_of_relation_ids $list_of_relation_ids"
# THIS PART DOESN'T WORK YET, NEED TO ITERATE OVER ALL IDs PROPERLY
relation-set -r $list_of_relation_ids mahrio_config=$NEW_CONFIG
status-set active "exiting... $(date +"%H:%M")"
juju-log -l "WARNING" "(add-domain) exiting..."
I am basing this off of this “old” doc… Juju documentation | Juju documentation