The Terraform oVirt provider is used to interact with the many resources supported by oVirt. In this guide, we will cover how you can install Terraform oVirt provider plugin and use it to automate oVirt / RHEV Virtualization environment operations. The provider needs to be configured with the proper credentials before it can be used.
Step 1: Install Go (if building from source)
We will build the plugin from source code. For this, we need Go (Golang) installed on the local workstation. Refer to our guides below and official Go documentation for how to steps.
Step 2: Install Terraform on your system
oVirt terraform provider requires Terraform installed on the machine from where the build is being done. Use the guide below to install Terraform:
Check version
$ terraform version
Terraform v1.3.7
on linux_amd64
Step 3: Install oVirt terraform provider
The oVirt Terraform provider can be used with Terraform 0.13+ from the Terraform registry:
$ vim main.tf
terraform {
required_providers {
ovirt = {
source = "ovirt/ovirt"
}
}
}
provider "ovirt" {
# Configuration options
}
Initialize oVirt terraform provider.
$ terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of ovirt/ovirt...
- Installing ovirt/ovirt v2.1.5...
- Installed ovirt/ovirt v2.1.5 (self-signed, key ID B577328E6942BFF8)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Step 4: Using the oVirt terraform provider
For creation of resources on your oVirt/RHEV environment, refer to:
The basic unit is the creation of provider configuration file
$ vim main.tf
provider "ovirt" {
username = "username@profile"
url = "https://ovirt/ovirt-engine/api"
password = "Password"
}
The following arguments are supported:
url
– (Required) The oVirt engine API URL. If omitted, theOVIRT_URL
environment variable is used.username
– (Required) The username for accessing oVirt engine API. If omitted, theOVIRT_USERNAME
environment variable is used.password
– (Required) The password of the user for accessing oVirt engine API. If omitted, theOVIRT_PASSWORD
environment variable is used.
After placing creating the file, run the following command to initialize it.
$ terraform init
Initializing provider plugins...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
The initialization is successful and you can start to use the plugin to automate oVirt/RHEL Virtualization management.
More guides:
- Deploy VM Instances on Hetzner Cloud with Terraform
- How To Provision VMs on KVM with Terraform
- Install a Server or Virtual Machine from ISO on oVirt / RHEV
- Create and Manage User Accounts on oVirt and RHEV