A few changes, see notes

* Add script to add dns records
* Tag nodes based on which hypervisor they are on
* Add extra DNS fields via MAAS
This commit is contained in:
2021-12-06 07:57:11 +00:00
parent 2a1925805a
commit 840d798c29
7 changed files with 77 additions and 2 deletions

69
add_dns_records.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/bin/bash
. functions.sh
get_ip_from_juju()
{
from_app=""
case $dns_name in
"landscape")
juju_name="landscape-haproxy"
from_app="true"
;;
"graylog"|"nagios")
juju_name=${dns_name}
from_app="true"
;;
"dashboard")
juju_name="openstack-dashboard"
;;
"neutron")
juju_name="neutron-api"
;;
"nova")
juju_name="nova-cloud-controller"
;;
*)
juju_name=${dns_name}
;;
esac
[[ -n "$from_app" ]] && juju status ${juju_name} --format json | jq .applications[\"${juju_name}\"].units[][\"public-address\"] | sed s/\"//g
[[ -z "$from_app" ]] && juju config ${juju_name} vip
}
add_record()
{
dns_name=$1
maas_dns_ip=$(get_ip_from_juju $dns_name)
dns_name_result=$(maas ${maas_profile} dnsresources read name=${dns_name}-internal)
if [[ -n $(echo $dns_name_result | jq .[]) ]] ; then
dns_id=$(echo $dns_name_result | jq .[].id)
dns_ip=$(maas ${maas_profile} dnsresource update ${dns_id} fqdn=${dns_name}-internal.example.com ip_addresses=${maas_dns_ip})
else
dns_ip=$(maas ${maas_profile} dnsresources create fqdn=${dns_name}-internal.example.com ip_addresses=${maas_dns_ip})
fi
dns_cname_result=$(maas ${maas_profile} dnsresource-records read rrtype=CNAME name=${dns_name})
if [[ -n $(echo $dns_cname_result | jq .[]) ]] ; then
dns_id=$(echo $dns_cname_result | jq .[].id)
dns_cname=$(maas ${maas_profile} dnsresource-record update ${dns_id} rrtype=cname rrdata=${dns_name}-internal.example.com.)
else
dns_cname=$(maas ${maas_profile} dnsresource-records create fqdn=${dns_name}.example.com rrtype=cname rrdata=${dns_name}-internal.example.com.)
fi
}
read_configs
maas_login
for app in ${maas_dns_names[*]} landscape graylog nagios ; do
add_record ${app}
done

View File

@@ -1,6 +1,7 @@
hypervisor_name=asrock01
hypervisor_ip=10.0.1.241
hypervisor_mac="a8:a1:59:44:70:ac"
hypervisor_tag="asrock"
ip_suffix=241

View File

@@ -1,6 +1,7 @@
hypervisor_name=asrock02
hypervisor_ip=10.0.1.242
hypervisor_mac="a8:a1:59:44:76:79"
hypervisor_tag="asrock"
ip_suffix=242

View File

@@ -1,6 +1,7 @@
hypervisor_name=asrock03
hypervisor_ip=10.0.1.243
hypervisor_mac="a8:a1:59:44:73:f0"
hypervisor_tag="asrock"
ip_suffix=243

View File

@@ -1,6 +1,7 @@
hypervisor_name=hp01
hypervisor_ip=10.0.1.251
hypervisor_mac="e0:07:1b:ff:27:48"
hypervisor_tag="hp"
ip_suffix=251

View File

@@ -23,5 +23,5 @@ maas_dhcp_end_postfix="99"
maas_spaces=(oam ceph-access ceph-replica overlay admin internal external)
maas_subnets=(10.0.1 10.0.2 10.0.3 10.0.4 10.0.5 10.0.6 192.168.1 )
maas_vlans=(300 301 302 303 304 305 1)
maas_dns_names=(aodh cinder dashboard glance heat keystone mysql neutron nova gnocchi)
maas_dns_ips=(211 212 213 214 215 216 217 218 219 220)
maas_dns_names=(aodh cinder dashboard glance heat keystone mysql neutron nova gnocchi contrail vault placement)
maas_dns_ips=(211 212 213 214 215 216 217 218 219 220 221 222 223)

View File

@@ -196,6 +196,8 @@ do_nodes()
maas_create_partitions ${system_id} &
elif [[ $function == "tag" ]] ; then
machine_add_tag ${system_id} ${node_type}
machine_add_tag ${system_id} ${hypervisor_name}
machine_add_tag ${system_id} ${hypervisor_tag}
fi
done
wait