wip: newvm: configure vm for dynamic inventory
parent
3a0ed3dbd5
commit
12edb1b152
32
newvm.sh
32
newvm.sh
|
@ -1,10 +1,12 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# vim: set sw=4 ts=4 sts=4 et :
|
# vim: set sw=4 ts=4 sts=4 et :
|
||||||
|
|
||||||
|
METADATA_XMLNS='http://du5t1n.me/xmlns/libvirt/metadata/'
|
||||||
|
|
||||||
memory=2048
|
memory=2048
|
||||||
vcpus=2
|
vcpus=2
|
||||||
disk_size=16
|
disk_size=16
|
||||||
kickstart=http://rosalina.pyrocufflink.blue/~dustin/kickstart/fedora.ks
|
kickstart=https://git.pyrocufflink.net/infra/kickstart/raw/branch/master/fedora.ks
|
||||||
fedora=$(rpm -E %fedora)
|
fedora=$(rpm -E %fedora)
|
||||||
network=network=prod
|
network=network=prod
|
||||||
dnsdomain=pyrocufflink.blue
|
dnsdomain=pyrocufflink.blue
|
||||||
|
@ -73,6 +75,20 @@ while [ $# -gt 0 ]; do
|
||||||
--domain=*)
|
--domain=*)
|
||||||
dnsdomain=${1#=*}
|
dnsdomain=${1#=*}
|
||||||
;;
|
;;
|
||||||
|
--cfg-branch)
|
||||||
|
shift
|
||||||
|
cfg_branch=$1
|
||||||
|
;;
|
||||||
|
--cfg-branch=*)
|
||||||
|
cfg_branch=${1#*=}
|
||||||
|
;;
|
||||||
|
--group)
|
||||||
|
shift
|
||||||
|
groups_xml="${groups_xml}<group name=\"${1}\"/>"
|
||||||
|
;;
|
||||||
|
--group=*)
|
||||||
|
groups_xml="${groups_xml}<group name=\"${1#*=}\"/>"
|
||||||
|
;;
|
||||||
--no-console|--noconsole)
|
--no-console|--noconsole)
|
||||||
console=false
|
console=false
|
||||||
;;
|
;;
|
||||||
|
@ -139,6 +155,7 @@ extra_args="${extra_args} inst.notmux quiet systemd.show_status=1 console=ttyS0"
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
--name ${name} \
|
--name ${name} \
|
||||||
|
--metadata title=${hostname} \
|
||||||
--memory ${memory} \
|
--memory ${memory} \
|
||||||
--cpu host \
|
--cpu host \
|
||||||
--location ${location} \
|
--location ${location} \
|
||||||
|
@ -153,10 +170,21 @@ set -- \
|
||||||
--boot uefi \
|
--boot uefi \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
if [ -n "${cfg_branch}" ]; then
|
||||||
|
set -- "$@" --qemu-commandline="-fw_cfg opt/dch/cfg-branch,string=${cfg_branch}"
|
||||||
|
fi
|
||||||
|
|
||||||
if $console; then
|
if $console; then
|
||||||
set -- "$@" --autoconsole text
|
set -- "$@" --autoconsole text
|
||||||
else
|
else
|
||||||
set -- "$@" --noautoconsole --wait -1
|
set -- "$@" --noautoconsole --wait -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec virt-install "$@"
|
(
|
||||||
|
virsh event --event lifecycle --loop | awk '/Started/{exit}'
|
||||||
|
virsh metadata ${name} --live --config ${METADATA_XMLNS} dch \
|
||||||
|
"<metadata><groups>${groups_xml}</groups></metadata>"
|
||||||
|
) &
|
||||||
|
|
||||||
|
virt-install "$@"
|
||||||
|
wait
|
||||||
|
|
Loading…
Reference in New Issue