newvm: Add host to some groups by default

There are some groups that all hosts should belong to in almost all
cases.  Rather than have to remember to add the `--group` arguments for
each of these, the `newvm.sh` script will now enable them by default.
For hosts that should _not_ belong to (at least one of) these groups,
the `--no-default-groups` argument can be provided to suppress that
behavior.

The default groups, initially, are _chrony_ and _collectd_.
unifi-restore
Dustin 2025-03-16 16:34:38 -05:00
parent c300dc1b6c
commit a423826fcd
1 changed files with 11 additions and 2 deletions

View File

@ -8,9 +8,10 @@ vcpus=2
disk_size=16
kickstart=https://git.pyrocufflink.net/infra/kickstart/raw/branch/master/fedora.ks
fedora=$(rpm -E %fedora)
network=network=prod
dnsdomain=pyrocufflink.blue
network=network=kube
dnsdomain=host.pyrocufflink.black
console=true
default_groups=true
usage() {
printf 'usage: %s [options] name\n' "${0##*/}"
@ -89,6 +90,9 @@ while [ $# -gt 0 ]; do
--group=*)
groups_xml="${groups_xml}<group name=\"${1#*=}\"/>"
;;
--no-default-groups)
default_groups=false;
;;
--no-console|--noconsole)
console=false
;;
@ -129,6 +133,11 @@ if [ -z "${LIBVIRT_DEFAULT_URI}" ]; then
exit 1
fi
if ${default_groups}; then
groups_xml="<group name=\"chrony\"/>${groups_xml}"
groups_xml="<group name=\"collectd\"/>${groups_xml}"
fi
printf 'Creating %s on %s\n' "${name}" "${LIBVIRT_DEFAULT_URI}"
if [ -z "${location}" ]; then