Skip to content

example on how to launch a ubuntu vm using terraform-libvirt

Notifications You must be signed in to change notification settings

rgl/terraform-libvirt-ubuntu-example

Repository files navigation

Usage (Ubuntu 22.04 host)

Lint

Create and install the base Ubuntu 22.04 vagrant box.

Install Terraform:

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

Create the infrastructure:

export CHECKPOINT_DISABLE=1
export TF_LOG=TRACE
export TF_LOG_PATH="$PWD/terraform.log"
terraform init
terraform plan -out=tfplan
time terraform apply tfplan

NB if you have errors alike Could not open '/var/lib/libvirt/images/terraform_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_example
virsh qemu-agent-command terraform_example '{"execute":"guest-info"}' --pretty
virsh qemu-agent-command terraform_example '{"execute":"guest-network-get-interfaces"}' --pretty
./qemu-agent-guest-exec terraform_example id
./qemu-agent-guest-exec terraform_example uname -a
ssh-keygen -f ~/.ssh/known_hosts -R "$(terraform output --raw ip)"
ssh "vagrant@$(terraform output --raw ip)"

Destroy the infrastructure:

time terraform destroy -auto-approve

List this repository dependencies (and which have newer versions):

GITHUB_COM_TOKEN='YOUR_GITHUB_PERSONAL_TOKEN' ./renovate.sh

Virtual BMC

You can externally control the VM using the following terraform providers:

About

example on how to launch a ubuntu vm using terraform-libvirt

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published