Skip to content

This manages a libvirt_domain VirtualBMC (vbmc) through the vbmc_vbmc terraform resource

Notifications You must be signed in to change notification settings

rgl/terraform-provider-vbmc

Repository files navigation

About

build terraform provider docker image

This manages a libvirt_domain VirtualBMC (vbmc) through the vbmc_vbmc resource.

For a Redfish based provider see the rgl/terraform-provider-sushy-vbmc source repository.

Usage (Ubuntu 20.04 host)

Install docker, vagrant, vagrant-libvirt, and the Ubuntu Base Box.

Install terraform:

wget https://releases.hashicorp.com/terraform/1.2.5/terraform_1.2.5_linux_amd64.zip
unzip terraform_1.2.5_linux_amd64.zip
sudo install terraform /usr/local/bin
rm terraform terraform_*_linux_amd64.zip

Install ipmitool:

sudo apt-get install -y ipmitool

Build the development version of this provider and install it:

NB This is only needed when you want to develop this plugin. If you just want to use it, let terraform init install it from the terraform registry.

make

Create the infrastructure:

terraform init
terraform plan -out=tfplan
terraform apply tfplan

NB if you have errors alike Could not open '/var/lib/libvirt/images/terraform_vbmc_example_root.img': Permission denied' you need to reconfigure libvirt by setting security_driver = "none" in /etc/libvirt/qemu.conf and restart libvirt with sudo systemctl restart libvirtd.

Show information about the libvirt/qemu guest:

virsh dumpxml terraform_vbmc_example
virsh qemu-agent-command terraform_vbmc_example '{"execute":"guest-info"}' --pretty

Create the vbmc_ipmitool alias to make ipmitool simpler to use:

alias vbmc_ipmitool="\
ipmitool \
-I lanplus \
-U admin \
-P password \
-H "$(terraform output --raw vbmc_address)" \
-p "$(terraform output --raw vbmc_port)" \
"

Show the power status:

vbmc_ipmitool chassis status
vbmc_ipmitool chassis power status

Do a soft power off (ACPI shutdown):

NB A soft power off will be handled by the qemu-ga daemon and the /var/log/syslog file contains the lines qemu-ga: info: guest-shutdown called, mode powerdown. and systemd: Stopped target Default..

vbmc_ipmitool chassis power soft # NB use "off" for a hard power off.
vbmc_ipmitool chassis power status

Set the machine boot device to PXE boot from the default network interface and power it on:

vbmc_ipmitool chassis bootdev pxe
vbmc_ipmitool chassis bootparam get 5 # get the current boot device.
vbmc_ipmitool chassis power on
vbmc_ipmitool chassis power status

Set the machine boot device to boot from the default disk and reset it:

vbmc_ipmitool chassis bootdev disk
vbmc_ipmitool chassis bootparam get 5 # get the current boot device.
vbmc_ipmitool chassis power reset # NB this is an hard-reset.

Destroy the infrastructure:

terraform destroy -target vbmc_vbmc.example # destroy just the vbmc.
terraform destroy -auto-approve # destroy everything.