Skip to content

UCL-ARC/ovirt-terraform-vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ovirt-terraform-vm

A Terraform module to provision an oVirt VM.

Usage

# main.tf
terraform {
    required_providers {
        ovirt = {
            source  = "local/ovirt/ovirt"
            version = "0.99.0"
        }
    }
}

provider "ovirt" {
    url = "https://<OVIRT_ENGINE_FQDN>/ovirt-engine/api"
}

# Create two VMs: test-01 and test-02
module "testvm" {

  count             = 2
  
  source            = "github.com/UCL-ARC/ovirt-terraform-vm//?ref=v0.1.0"
  cluster_id        = "<OVIRT_CLUSTER_ID>"
  vm_name           = "${format("test-%02d", count.index + 1)}"
  vm_hostname       = "${format("test-%02d", count.index + 1)}"

  vm_cpu_cores      = "4"
  vm_memory         = "16384"

  vm_template_id    = "<OVIRT_VM_TEMPLATE_ID>"

  vm_dns_servers    = "<DNS_SERVER>"
  vm_dns_search     = "<DNS_SEARCH_DOMAIN>"
  vm_nic_device     = "eth0"
  vm_nic_boot_proto = "dhcp"
  vm_nic_gateway    = "192.168.10.254"
  vm_nic_netmask    = "255.255.255.0"

  # If using static instead of DHCP:
  #vm_nic_ip_address = "192.168.10.11"

  vm_timezone = "Europe/London"

  vm_authorized_ssh_key = "ssh-rsa <MYKEY>="
}

How to build, configure and use the oVirt provider on RHEL 8

  • Install go.
  • Build the oVirt provider.
  • Create a local plugin directory.
# Install go toolchain 
sudo dnf -y install make
sudo yum module -y install go-toolset
# Clone and build provider
PROVIDER_VER=v0.99.0
git clone https://github.com/oVirt/terraform-provider-ovirt.git
cd terraform-provider-ovirt/
git checkout $PROVIDER_VER
make build
# Create local plugin directory
OVIRT_PLUGIN_DIR=~/.terraform.d/plugins/local/ovirt/ovirt/$PROVIDER_VER/linux_amd64
mkdir $OVIRT_PLUGIN_DIR
cp $GOPATH/bin/terraform-provider-ovirt $OVIRT_PLUGIN_DIR/terraform-provider-ovirt_$PROVIDER_VER

# Change to your source directory
# Set oVirt credentials in env. variables
export HISTCONTROL=ignorespace
export OVIRT_USERNAME=<USER>@internal
 export OVIRT_PASSWORD=<MYPASSWORD>
# Initialise terraform
terraform init
# Plan and apply
terraform plan -out plan.out
terraform apply plan.out

References

About

Build VMs on an oVirt platform with Terraform

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages