From c15b9a8b713839f915818b057706873ae306a3ee Mon Sep 17 00:00:00 2001 From: Anton Smith Date: Wed, 3 Nov 2021 17:37:29 +0100 Subject: [PATCH] automated getting the VM host ID using the hostname --- maas-setup.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/maas-setup.sh b/maas-setup.sh index cf7c9e3..4b0a167 100644 --- a/maas-setup.sh +++ b/maas-setup.sh @@ -39,19 +39,20 @@ maas admin vm-hosts create password=password type=lxd power_address=https://${ # creating VMs # TODO find out the name of our vm host, and store this id in a variable -maas admin vm-hosts read | jq '.[] | select (.name=="proud-possum") | .name, .id' + +export VM_HOST_ID=maas admin vm-hosts read | jq -r --arg VM_HOST "$(hostname)" '.[] | select (.name==$VM_HOST) | .id' # add a VM for the juju controller with minimal memory # TODO use the variable for the VM host ID (below it is static 1). If you don't have 8 cores, change this to 4. -maas admin vm-host compose 1 cores=8 memory=2048 architecture="amd64/generic" storage="main:16(pool1)" +maas admin vm-host compose $VM_HOST_ID cores=8 memory=2048 architecture="amd64/generic" storage="main:16(pool1)" #TODO get the system_id from output of above, and use it with: # maas admin tag update-nodes "juju-controller" add=$SYSTEM-ID ## Create 3 "bare metal" machines -maas admin vm-host compose 1 cores=8 memory=8192 architecture="amd64/generic" storage="main:25(pool1),ceph:150(pool1)" hostname="metal-1" +maas admin vm-host compose $VM_HOST_ID cores=8 memory=8192 architecture="amd64/generic" storage="main:25(pool1),ceph:150(pool1)" hostname="metal-1" # TODO grab system-id and tag machine "metal" -maas admin vm-host compose 1 cores=8 memory=8192 architecture="amd64/generic" storage="main:25(pool1),ceph:150(pool1)" hostname="metal-2" +maas admin vm-host compose $VM_HOST_ID cores=8 memory=8192 architecture="amd64/generic" storage="main:25(pool1),ceph:150(pool1)" hostname="metal-2" # TODO grab system-id and tag machine "metal" -maas admin vm-host compose 1 cores=8 memory=8192 architecture="amd64/generic" storage="main:25(pool1),ceph:150(pool1)" hostname="metal-3" +maas admin vm-host compose $VM_HOST_ID cores=8 memory=8192 architecture="amd64/generic" storage="main:25(pool1),ceph:150(pool1)" hostname="metal-3" # TODO grab system-id and tag machine "metal" # Go to the MAAS UI, log in with username admin password admin, and tag the machines