Enhancement Request: Add `vagrant define` subcommand
Feature Request: Add vagrant define Subcommand
Is your feature request related to a problem? Please describe.
Currently, when using vagrant-libvirt, Vagrant automatically creates and starts a domain upon running vagrant up. However, in certain scenarios, users may want to only define the domain without starting it. One specific use case is when a user wants to take a snapshot of the VM in an untouched state before its first boot.
This limitation makes it difficult to:
- Create snapshots before first boot (useful for forensic analysis, golden images, etc.).
- Inspect or modify the libvirt domain XML before execution.
- Set up multi-VM configurations where some machines should not start immediately.
Describe the solution you'd like
Introduce a new subcommand:
vagrant define
This command would behave similarly to vagrant up, but instead of booting the VM, it would only define the domain in libvirt. This allows:
- Creating a libvirt domain from Vagrant’s configuration.
- Using standard libvirt tooling (e.g.,
virsh snapshot-create-as) to take an untouched snapshot before the VM runs. - Further manual modifications to the VM definition before starting.
Behavior:
- Runs the provisioning pipeline up to the point of defining the domain, then stops.
- Does not boot the VM.
- The next
vagrant upwould recognize that the domain is already defined and proceed with normal startup.
Describe alternatives you've considered
No real alternatives as vagrant up with vagrant-libvirt creates the libvirt XML and the VM in one go
Would love to hear feedback from maintainers and the community on whether this feature would be a good addition to Vagrant.