From 6549ec4ee43d6453d7e6497cb7fd9551ab9c34d0 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Sat, 25 Dec 2021 18:47:41 +0000 Subject: [PATCH] Add domain, if it doesn't exist --- add_dns_records.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/add_dns_records.sh b/add_dns_records.sh index aae629f..394707f 100755 --- a/add_dns_records.sh +++ b/add_dns_records.sh @@ -2,6 +2,18 @@ . functions.sh +setup_domain() +{ + domains=$(maas ${maas_profile} domains read) + + my_domain=$(echo $domains | jq '.[] | select(.name=="example.com")') + + if [[ -z $my_domain ]] ; then + + maas ${maas_profile} domains create name="example.com" + fi +} + get_ip_from_juju() { from_app="" @@ -64,6 +76,8 @@ add_record() read_configs maas_login +setup_domain + for app in ${maas_dns_names[*]} landscape graylog nagios ; do add_record ${app} done