2024-04-04 12:41:58 +02:00
# Vagrant instructions
2024-04-04 21:23:45 +02:00
### Install libvirt and QEMU/KVM
2024-04-10 11:35:33 +02:00
Follow [PBot VM Prerequisites ](../../../doc/VirtualMachine.md#prerequisites ) up to the [libvirt and QEMU ](../../../doc/VirtualMachine.md#libvirt-and-qemu-1 )
section, then return to this guide. If you've reached the section about making
a `pbot-vm` user, adding yourself to the `libvirt` group or downloading any ISOs
then you've read too far!
2024-04-04 21:23:45 +02:00
2024-04-04 12:41:58 +02:00
### Install Vagrant
To install vagrant on openSUSE, use:
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
zypper install --no-recommends vagrant
2024-04-04 12:41:58 +02:00
Otherwise see https://vagrant-libvirt.github.io/vagrant-libvirt/installation.html for installation instructions for your platform.
### Install vagrant-libvirt
vagrant plugin install vagrant-libvirt
### Start Vagrant Box
2024-04-04 21:23:45 +02:00
To start a virtual machine, `cd` into one of the PBot-VM Vagrant sub-directories and run the following command. This will download
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
the appropriate virtual machine image and automatically configure it as the default PBot VM Guest, `pbot-vm` described by
[`host/config/vm-exec.json` ](../host/config/vm-exec.json ):
2024-04-04 12:41:58 +02:00
vagrant up
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
You may pass optional environment variables to override pbot-vm default configuration (see [PBot VM Environment Variables ](../../../doc/VirtualMachine.md#environment-variables )).
For example, to create `pbot-test-vm` described by [`host/config/vm-exec.json` ](../host/config/vm-exec.json ):
2024-04-04 12:41:58 +02:00
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
PBOTVM_DOMAIN=pbot-test-vm PBOTVM_SERIAL=7777 PBOTVM_HEALTH=7778 vagrant up
2024-04-04 12:41:58 +02:00
2024-04-04 21:23:45 +02:00
### Connect to Vagrant Box
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
Use SSH to connect to the PBot VM Guest:
2024-04-04 21:23:45 +02:00
vagrant ssh
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
If you specified a `PBOTVM_DOMAIN` , e.g. `pbot-test-vm` , you must specify it:
PBOTVM_DOMAIN=pbot-test-vm vagrant ssh
2024-04-04 21:23:45 +02:00
### Start PBot VM Guest Server
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
Once connected to the PBot VM Guest via SSH, start `guest-server` in the background:
sudo nohup guest-server & > log &
2024-04-04 21:23:45 +02:00
Some distributions may require you to specify the full path:
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
sudo nohup /usr/local/bin/guest-server & > log &
2024-04-04 21:23:45 +02:00
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
### Disconnect from Vagrant Box
2024-04-04 21:23:45 +02:00
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
Now you can type `logout` to exit the PBot VM Guest.
2024-04-04 21:23:45 +02:00
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
### Create snapshot of PBot VM Guest
2024-04-04 21:23:45 +02:00
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
After you've logged out of the PBot VM Guest with `guest-server` running in the background, create a snapshot. This allows PBot to revert to a known good state when a command times out.
If a `PBOTVM_DOMAIN` was defined, replace `pbot-vm` with that name.
virsh -c qemu:///system snapshot-create-as pbot-vm 1
2024-04-04 21:23:45 +02:00
pbot-vm: massive refactor
* replace heartbeat with health-check
* instead of steady stream of newlines every 5s, now awaits input
and responds with `vmstat` output
* more reliably use host/config/vm-exec.json to get libvirt domain name
for snapshot-revert, server address, serial ports, vagrant setting, etc
* use iptables/nftables to disable networking
* added guest/bin/disable-network-[iptables,nftables]
* added guest/bin/enable-network-[iptables,nftables]
* replace ugly ___OUTPUT___ texts in sh, bash, ksh, zsh languages
* documentation updates and tweaks
2024-04-10 10:21:18 +02:00
### Edit vm-exec.json
If you used `vagrant up` without specifying a `PBOTVM_DOMAIN` , you must edit the [`../host/config/vm-exec.json` ](../host/config/vm-exec.json )
configuration file to set the `vagrant` value to `1` for the `pbot-vm` machine.
If you have specified a `PBOTVM_DOMAIN` , ensure the appropriate entries exist in the `vm-exec.json` configuration file.
By default, `pbot-test-vm` already has `vagrant` set to `1` .
### Start PBot VM Host Server
cd ../host/bin/
./vm-server
### Test PBot VM
2024-04-04 21:23:45 +02:00
In your instance of PBot, the `sh` and `cc` , etc, commands should now produce output:
< pragma- > sh echo Hello world!
< PBot > Hello world!
2024-04-04 12:41:58 +02:00
### Shutdown Vagrant Box
vagrant halt
### Destroy Vagrant Box
vagrant destroy
### Delete Vagrant Box
vagrant box list
vagrant box remove < name >
2024-04-04 21:23:45 +02:00
### (Optional) Install Alternative Vagrant Box
2024-04-04 12:41:58 +02:00
To install an alternative Vagrant box with your preferred OS/distribution, search for one at https://app.vagrantup.com/boxes/search
2024-04-04 21:23:45 +02:00
and then make a new directory, e.g. FreeBSD-14, and copy one of the existing PBot-VM Vagrantfiles into
this directory, and then edit the `config.vm.box` line to point at the chosen OS/distribution, e.g. `freebsd/FreeBSD-14.0-CURRENT` .
Some boxes may have specific settings that you may need to copy over. To obtain and examine the box's Vagrantfile:
2024-04-04 12:41:58 +02:00
vagrant init < OS / distribution >
Examples:
vagrant init debian/testing64
vagrant init debian/bookworm64
vagrant init opensuse/Tumbleweed.x86_64
vagrant init archlinux/archlinux
vagrant init freebsd/FreeBSD-14.0-CURRENT
vagrant init generic/openbsd7
Then use one of the existing PBot-VM Vagrantfiles as a guide for adjusting your alternative Vagrantfile.