Commit Graph

12 Commits (c7374c8cca4afb0a272e8256aa3179db95b2c482)

Author SHA1 Message Date
Dustin b4f5b419e1 newvm: Stop waiting for VM events if install fails
If `virt-install` fails before the VM starts for the first time; the
`virsh event` process running in the background will never terminate and
therefore the main process will `wait` forever.  We can avoid this by
killing the background process if `virt-install` fails.
2025-07-14 15:57:12 -05:00
Dustin 51e8cae618 newvm: Fix vCPU count/CPU model
Although the `newvm.sh` script had a `--vcpus` argument, its value was
never being used.

The `--cpu host` argument for `virt-install` is deprecated in favor of
`--cpu host`.
2025-07-14 15:57:12 -05:00
Dustin 04718fa6d0 newvm: Avoid adding graphics adapter by default
VMs don't really need graphical consoles; serial terminals are good
enough, or even better given that they are logged.  For the few cases
where a graphical console is actually necessary, the `newvm.sh` script
can add one with the `--graphics` argument.
2025-07-14 15:57:12 -05:00
Dustin 0824e6bea0 newvm: Update default kickstart location
Since the kickstart scripts are now generated from templates by Jenkins,
we need to fetch the final rendered artifacts from the PXE server,
rather than the source files from Gitea.
2025-07-14 15:57:12 -05:00
Dustin a423826fcd 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_.
2025-03-16 16:37:19 -05:00
Dustin 757494b48b newvm: Use kickstart from Gitea by default
The canonical location for kickstart scripts has _finally_ moved to
a real server instead of my desktop...
2025-02-08 16:49:14 -06:00
Dustin e7de5142f3 newvm: Allow setting cfgpol branch
The script that runs on first boot of a new machine that triggers
host provisioning can read the name of the configuration policy branch
to checkout from the QEMU firmware configuration option.  This commit
adds a `--cfg-branch` argument to `newvm.sh` that sets that value.  This
will be useful for testing new policy on a new VM.
2025-02-08 16:49:14 -06:00
Dustin 4d30798f54 newvm: Configure VM for dynamic inventory
This commit adds a new `--group` argument to the `newvm` script, which
adds the host to an Ansible group by listing it in the _libvirt_ domain
metadata.  Multiple groups can be specified by repeating the argument.
Additionally, the VM title is now always set to machine's FQDN, which
is what the dynamic inventory plugin uses to determine the inventory
hostname.

The dynamic inventory plugin parses the _libvirt_ domain metadata and
extracts group membership from the `<dch:groups>` XML element.  Each
`<dch:group>` sub-element specifies a group to which the host belongs.

Unfortunately, `virt-install` does not support modifying the
`<metadata>` element in the _libvirt_ domain XML document, so we have
to resort to using `virsh`.  To ensure the metadata are set before the
guest OS boots and tries to access them, we fork and run `virsh` in
a separate process.
2025-02-08 15:35:34 -06:00
Dustin e41b6a619e 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.
2024-11-24 10:33:21 -06:00
Dustin 75a146e19e newvm: Configure serial console log file
When a VM uses a serial port for its default console, kernel messages
(e.g. panics) are lost if no console client is connected at the time.
This is a major disadvantage when compared to a graphical console, which
usually at least keeps a "screenshot" of the console when the kernel
crashes.

While researching the available console device types to determine how
best to implement a tool that would both log the output from the serial
console at all times, while still allowing interactive connections to
it, I discovered that _libvirt_ actually already has this exact
functionality built-in:

https://libvirt.org/formatdomain.html#consoles-serial-parallel-channel-devices
2024-10-13 18:12:46 -05:00
Dustin 8239b60634 newvm: Add --network argument
Although the `newvm.sh` script had a variable to configure the value
specified for the `--network` argument to `virt-install`, it didn't
expose a way to set it.  We need this ability so we can e.g. create VMs
on non-default networks like `camera` or `mgmt`.
2024-08-12 18:47:04 -05:00
Dustin 056548e3e0 newvm: Add script to run virt-install
For the longest time, whenever I needed to create a new virtual machine,
I just used `Ctrl+R` to find the last `virt-install` command I had run
and tweaked it for the new machine.  At some point, my `~/.zsh_history`
overflowed, though, so the command I had been running got lost.  To
avoid this silliness in the future, I've created a script that runs
`virt-manager` for me.  As a bonus, it has some configuration flags for
the parameters that often vary between machines.  For most machines,
though, the script can be run as simply as `newvm.sh name`.
2024-07-02 20:44:29 -05:00