newvm: Add domain argument

Now that we have multiple domains (_pyrocufflink.blue_ for AD domain
members and _pyrocufflink.black_ for the new machines), we need a way to
specify the domain for new machines when they are created.  Thus, the
`newvm.sh` script accepts either an FQDN or a `--domain` argument.  The
DHCP server will register the DNS name in the zone containing the
machine's domain name.
dynamic-inventory
Dustin 2024-11-23 20:32:49 -06:00
parent 7a5f01f8a3
commit e41b6a619e
1 changed files with 19 additions and 1 deletions

View File

@ -7,6 +7,7 @@ disk_size=16
kickstart=http://rosalina.pyrocufflink.blue/~dustin/kickstart/fedora.ks
fedora=$(rpm -E %fedora)
network=network=prod
dnsdomain=pyrocufflink.blue
console=true
usage() {
@ -65,6 +66,13 @@ while [ $# -gt 0 ]; do
--network=*)
network="${1#*=}"
;;
--domain)
shift
dnsdomain=$1
;;
--domain=*)
dnsdomain=${1#=*}
;;
--no-console|--noconsole)
console=false
;;
@ -88,6 +96,16 @@ if [ -z "${name}" ]; then
exit 2
fi
case ${name} in
*.*)
hostname=${name}
name=${name%%.*}
;;
*)
hostname=${name}.${dnsdomain}
;;
esac
if [ -z "${LIBVIRT_DEFAULT_URI}" ]; then
printf 'LIBVIRT_DEFAULT_URI is not set.\n' >&2
printf 'If you want to create a new VM locally, explicitly set '
@ -110,7 +128,7 @@ else
printf 'Using HTTP proxy: %s\n' "${http_proxy}" >&2
fi
extra_args="ip=::::${name}::dhcp inst.ks=${kickstart}"
extra_args="ip=::::${hostname}::dhcp inst.ks=${kickstart}"
if [ -n "${http_proxy}" ]; then
extra_args="${extra_args} inst.proxy=${http_proxy}"
if [ ${fedora} -lt 40 ]; then