VMware Aria Automation
9 minute read
To learn more about this OneFuse Module, refer to Aria Automation.
Prerequisites
- Configure the OneFuse Provider
- Review an overview on OneFuse Modules with Terraform
Steps
-
Create
variables.tffile -
Create
main.tffile -
Run terraform commands to deploy a VMware Aria Automation Deployment:
-
terraform init -
terraform plan -
terraform apply -
Example apply output:
Initializing the backend... Initializing provider plugins... - Reusing previous version of cloudboltsoftware/onefuse from the dependency lock file - Using previously-installed cloudboltsoftware/onefuse v1.20.0 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. An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # onefuse_vra_deployment.my_vra_deployment will be created + resource "onefuse_vra_deployment" "my_vra_deployment" { + blueprint_name = (known after apply) + deployment_info = (known after apply) + deployment_name = "tf_vra_deployment" + id = (known after apply) + policy_id = 1 + project_name = (known after apply) + template_properties = { + "Environment" = "Dev" } + workspace_url = (known after apply) } Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + deployment_info = (known after apply) ------------------------------------------------------------------------ Note: You didn't specify an "-out" parameter to save this plan, so Terraform can't guarantee that exactly these actions will be performed if "terraform apply" is subsequently run. An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # onefuse_vra_deployment.my_vra_deployment will be created + resource "onefuse_vra_deployment" "my_vra_deployment" { + blueprint_name = (known after apply) + deployment_info = (known after apply) + deployment_name = "tf_vra_deployment" + id = (known after apply) + policy_id = 1 + project_name = (known after apply) + template_properties = { + "Environment" = "Dev" } + workspace_url = (known after apply) } Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + deployment_info = (known after apply) Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes onefuse_vra_deployment.my_vra_deployment: Creating... onefuse_vra_deployment.my_vra_deployment: Still creating... [10s elapsed] ... onefuse_vra_deployment.my_vra_deployment: Creation complete after 21m9s [id=1] Apply complete! Resources: 1 added, 0 changed, 0 destroyed. Outputs: deployment_info = "{\"blueprintId\":\"30adbde1-914b-48ae-80d5-38f67a0a76fd\",\"blueprintVersion\":\"1\",\"childResources\":[{\"createdAt\":\"2021-04-07T20:12:59.012526Z\",\"id\":\"89a59c4d-b64f-407f-a393-fe391c9023d5\",\"name\":\"Cloud_vSphere_Machine_1\",\"properties\":{\"account\":\"vcenter.company.com\",\"componentType\":\"Cloud.vSphere.Machine\",\"computeHostRef\":\"ResourcePool:resgroup-223319\",\"computeHostType\":\"ResourcePool\",\"coreCount\":\"1\",\"cpuCount\":1,\"datastoreName\":\"XtremIO\",\"endpointId\":\"0cf54d7c-f889-42b2-9596-275723a4442b\",\"endpointType\":\"vsphere\",\"flavorMappingName\":\"\",\"id\":\"/resources/compute/89a59c4d-b64f-407f-a393-fe391c9023d5\",\"imageRef\":\"MassTesting\",\"name\":\"Cloud_vSphere_Machine_1\",\"networks\":[{\"assignment\":\"dynamic\",\"deviceIndex\":0,\"id\":\"/resources/network-interfaces/184557fe-7a0f-4eff-94c4-87dd4e5df2f1\",\"mac_address\":\"00:50:56:a5:10:ac\",\"name\":\"dvs_102_10.10.2.0_24\",\"resourceName\":\"dvs_102_10.10.2.0_24\"}],\"osType\":\"LINUX\",\"powerState\":\"ON\",\"primaryMAC\":\"00:50:56:a5:10:ac\",\"project\":\"ae8d2e8e-ace6-4bf2-916a-bb10aa731d1b\",\"providerId\":\"5025e14b-38b7-8ea0-ce5b-580eb8bee60d\",\"provisionGB\":\"0\",\"region\":\"onefuse\",\"resourceDescLink\":\"/resources/compute-descriptions/efd6c152-6bab-4a78-af9f-079743f09cbb\",\"resourceId\":\"89a59c4d-b64f-407f-a393-fe391c9023d5\",\"resourceLink\":\"/resources/compute/89a59c4d-b64f-407f-a393-fe391c9023d5\",\"resourceName\":\"vrauserqa-976\",\"resourcePool\":\"/resources/pools/7248f32e8f9b5c75-7f703c5265a63d87\",\"softwareName\":\"Other (64-bit)\",\"storage\":{\"disks\":[{\"bootOrder\":1,\"capacityGb\":0,\"controllerKey\":\"1000\",\"controllerUnitNumber\":\"0\",\"diskPlacementRef\":\"StoragePod:group-p100\",\"encrypted\":false,\"independent\":\"false\",\"name\":\"vrauserqa-976-boot-disk\",\"persistent\":false,\"provisionGB\":\"0\",\"provisioningType\":\"thin\",\"type\":\"HDD\",\"vcUuid\":\"634f89cd-bcf8-421b-bfa3-65f09557abca\",\"vm\":\"VirtualMachine:vm-710951\"}]},\"totalMemoryMB\":1024,\"vcUuid\":\"634f89cd-bcf8-421b-bfa3-65f09557abca\",\"zone\":\"Cluster1 / ESX Agents\",\"zone_overlapping_migrated\":\"true\"},\"state\":\"OK\",\"type\":\"Cloud.vSphere.Machine\"}],\"createdAt\":\"2021-04-07T20:12:42.249541Z\",\"createdBy\":\"vrauser\",\"description\":\"\",\"id\":\"6162920c-d7df-4018-b843-0bb5e68873b7\",\"inputs\":{\"cpuCount\":1,\"totalMemoryMB\":1024},\"lastUpdatedAt\":\"2021-04-07T20:33:29.905193Z\",\"lastUpdatedBy\":\"vrauser\",\"name\":\"tf_vra_deployment\",\"orgId\":\"c1cb7d03-37ee-4fbe-a052-6d2c4af5a8a8\",\"ownedBy\":\"vrauser\",\"projectId\":\"ae8d2e8e-ace6-4bf2-916a-bb10aa731d1b\",\"status\":\"CREATE_SUCCESSFUL\"}"
-
-
Run terraform command to destroy Aria Automation Deployment:
-
terraform destroy -
Example destroy output:
An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: - destroy Terraform will perform the following actions: # onefuse_vra_deployment.my_vra_deployment will be destroyed - resource "onefuse_vra_deployment" "my_vra_deployment" { - blueprint_name = "myblueprint" -> null - deployment_info = jsonencode( { - blueprintId = "30adbde1-914b-48ae-80d5-38f67a0a76fd" - blueprintVersion = "1" - childResources = [ - { - createdAt = "2021-04-07T20:12:59.012526Z" - id = "89a59c4d-b64f-407f-a393-fe391c9023d5" - name = "Cloud_vSphere_Machine_1" - properties = { - account = "vcenter01.company.com" - componentType = "Cloud.vSphere.Machine" - computeHostRef = "ResourcePool:resgroup-223319" - computeHostType = "ResourcePool" - coreCount = "1" - cpuCount = 1 - datastoreName = "XtremIO_5t_datastore3" - endpointId = "0cf54d7c-f889-42b2-9596-275723a4442b" - endpointType = "vsphere" - flavorMappingName = "" - id = "/resources/compute/89a59c4d-b64f-407f-a393-fe391c9023d5" - imageRef = "MassTesting" - name = "Cloud_vSphere_Machine_1" - networks = [ - { - assignment = "dynamic" - deviceIndex = 0 - id = "/resources/network-interfaces/184557fe-7a0f-4eff-94c4-87dd4e5df2f1" - mac_address = "00:50:56:a5:10:ac" - name = "dvs_102_10.10.2.0_24" - resourceName = "dvs_102_10.10.2.0_24" }, ] - osType = "LINUX" - powerState = "ON" - primaryMAC = "00:50:56:a5:10:ac" - project = "ae8d2e8e-ace6-4bf2-916a-bb10aa731d1b" - providerId = "5025e14b-38b7-8ea0-ce5b-580eb8bee60d" - provisionGB = "0" - region = "onefuse" - resourceDescLink = "/resources/compute-descriptions/efd6c152-6bab-4a78-af9f-079743f09cbb" - resourceId = "89a59c4d-b64f-407f-a393-fe391c9023d5" - resourceLink = "/resources/compute/89a59c4d-b64f-407f-a393-fe391c9023d5" - resourceName = "vrauserqa-976" - resourcePool = "/resources/pools/7248f32e8f9b5c75-7f703c5265a63d87" - softwareName = "Other (64-bit)" - storage = { - disks = [ - { - bootOrder = 1 - capacityGb = 0 - controllerKey = "1000" - controllerUnitNumber = "0" - diskPlacementRef = "StoragePod:group-p100" - encrypted = false - independent = "false" - name = "vrauserqa-976-boot-disk" - persistent = false - provisionGB = "0" - provisioningType = "thin" - type = "HDD" - vcUuid = "634f89cd-bcf8-421b-bfa3-65f09557abca" - vm = "VirtualMachine:vm-710951" }, ] } - totalMemoryMB = 1024 - vcUuid = "634f89cd-bcf8-421b-bfa3-65f09557abca" - zone = "Cluster1 / ESX Agents" - zone_overlapping_migrated = "true" } - state = "OK" - type = "Cloud.vSphere.Machine" }, ] - createdAt = "2021-04-07T20:12:42.249541Z" - createdBy = "vrauser" - description = "" - id = "6162920c-d7df-4018-b843-0bb5e68873b7" - inputs = { - cpuCount = 1 - totalMemoryMB = 1024 } - lastUpdatedAt = "2021-04-07T20:33:29.905193Z" - lastUpdatedBy = "vrauser" - name = "tf_vra_deployment" - orgId = "c1cb7d03-37ee-4fbe-a052-6d2c4af5a8a8" - ownedBy = "vrauser" - projectId = "ae8d2e8e-ace6-4bf2-916a-bb10aa731d1b" - status = "CREATE_SUCCESSFUL" } ) -> null - deployment_name = "tf_vra_deployment" -> null - id = "1" -> null - policy_id = 1 -> null - project_name = "Quickstart Project 1" -> null - template_properties = { - "Environment" = "Dev" } -> null - workspace_url = "/api/v3/onefuse/workspaces/2/" -> null } Plan: 0 to add, 0 to change, 1 to destroy. Changes to Outputs: - deployment_info = jsonencode( { - blueprintId = "30adbde1-914b-48ae-80d5-38f67a0a76fd" - blueprintVersion = "1" - childResources = [ - { - createdAt = "2021-04-07T20:12:59.012526Z" - id = "89a59c4d-b64f-407f-a393-fe391c9023d5" - name = "Cloud_vSphere_Machine_1" - properties = { - account = "vcenter01.company.com" - componentType = "Cloud.vSphere.Machine" - computeHostRef = "ResourcePool:resgroup-223319" - computeHostType = "ResourcePool" - coreCount = "1" - cpuCount = 1 - datastoreName = "XtremIO_datastore3" - endpointId = "0cf54d7c-f889-42b2-9596-275723a4442b" - endpointType = "vsphere" - flavorMappingName = "" - id = "/resources/compute/89a59c4d-b64f-407f-a393-fe391c9023d5" - imageRef = "MassTesting" - name = "Cloud_vSphere_Machine_1" - networks = [ - { - assignment = "dynamic" - deviceIndex = 0 - id = "/resources/network-interfaces/184557fe-7a0f-4eff-94c4-87dd4e5df2f1" - mac_address = "00:50:56:a5:10:ac" - name = "dvs_102_10.10.2.0_24" - resourceName = "dvs_102_10.10.2.0_24" }, ] - osType = "LINUX" - powerState = "ON" - primaryMAC = "00:50:56:a5:10:ac" - project = "ae8d2e8e-ace6-4bf2-916a-bb10aa731d1b" - providerId = "5025e14b-38b7-8ea0-ce5b-580eb8bee60d" - provisionGB = "0" - region = "onefuse" - resourceDescLink = "/resources/compute-descriptions/efd6c152-6bab-4a78-af9f-079743f09cbb" - resourceId = "89a59c4d-b64f-407f-a393-fe391c9023d5" - resourceLink = "/resources/compute/89a59c4d-b64f-407f-a393-fe391c9023d5" - resourceName = "vrauserqa-976" - resourcePool = "/resources/pools/7248f32e8f9b5c75-7f703c5265a63d87" - softwareName = "Other (64-bit)" - storage = { - disks = [ - { - bootOrder = 1 - capacityGb = 0 - controllerKey = "1000" - controllerUnitNumber = "0" - diskPlacementRef = "StoragePod:group-p100" - encrypted = false - independent = "false" - name = "vrauserqa-976-boot-disk" - persistent = false - provisionGB = "0" - provisioningType = "thin" - type = "HDD" - vcUuid = "634f89cd-bcf8-421b-bfa3-65f09557abca" - vm = "VirtualMachine:vm-710951" }, ] } - totalMemoryMB = 1024 - vcUuid = "634f89cd-bcf8-421b-bfa3-65f09557abca" - zone = "Cluster1 / ESX Agents" - zone_overlapping_migrated = "true" } - state = "OK" - type = "Cloud.vSphere.Machine" }, ] - createdAt = "2021-04-07T20:12:42.249541Z" - createdBy = "vrauser" - description = "" - id = "6162920c-d7df-4018-b843-0bb5e68873b7" - inputs = { - cpuCount = 1 - totalMemoryMB = 1024 } - lastUpdatedAt = "2021-04-07T20:33:29.905193Z" - lastUpdatedBy = "vrauser" - name = "tf_vra_deployment" - orgId = "c1cb7d03-37ee-4fbe-a052-6d2c4af5a8a8" - ownedBy = "vrauser" - projectId = "ae8d2e8e-ace6-4bf2-916a-bb10aa731d1b" - status = "CREATE_SUCCESSFUL" } ) -> null Do you really want to destroy all resources? Terraform will destroy all your managed infrastructure, as shown above. There is no undo. Only 'yes' will be accepted to confirm. Enter a value: yes onefuse_vra_deployment.my_vra_deployment: Destroying... [id=1] onefuse_vra_deployment.my_vra_deployment: Still destroying... [id=1, 10s elapsed] onefuse_vra_deployment.my_vra_deployment: Still destroying... [id=1, 20s elapsed] onefuse_vra_deployment.my_vra_deployment: Still destroying... [id=1, 30s elapsed] onefuse_vra_deployment.my_vra_deployment: Still destroying... [id=1, 40s elapsed] onefuse_vra_deployment.my_vra_deployment: Destruction complete after 43s Destroy complete! Resources: 1 destroyed.
-
Create variables.tf
Add the following in the variables.tf file. Update the values as needed.
It is a best practice to separate configurations into identifiable files, refer to Best practices for OneFuse modules.
The sample below shows all configurations in one variables.tf file for simplicity.
// SAMPLE VARIABLES.TF FILE CONFIGURATIONS
variable "onefuse_scheme" {
type = string
default = "https"
}
variable "onefuse_address" {
type = string
}
variable "onefuse_port" {
type = string
default = "443"
}
variable "onefuse_user" {
type = string
default = "admin"
}
variable "onefuse_password" {
type = string
default = "admin"
}
variable "onefuse_verify_ssl" {
type = bool
default = false
}
variable "workspace_url" {
type = string
default = "" // Default
}
variable "template_properties" {
type = map
default = {
"Environment" = "d" //p for production or d for development
"Location" = "w" //e for East or w for West
"Application" = "wp" //wp for wordpress or iis for IIS
"OS" = "l" //l for Linux or w for Windows
}
}
Create main.tf for Aria Automation resource
Add the following in the main.tf file. Update the values as needed.
Parameter references
The following defines the function of each Aria Automation specific parameter.
| Parameter name | Required? | Notes |
|---|---|---|
policy_id |
Required | OneFuse Module Policy ID (integer). |
workspace_url |
Optional | OneFuse Workspace URL path. Use "" for the default workspace. |
template_properties |
Optional | Additional properties that are referenced within the Policy. |
Aria Automation specific parameters:
| Parameter name | Required? | Notes |
|---|---|---|
deployment_name |
Required | Name of the vRA Deployment |
timeouts |
Optional | Timeout (in minutes) for create and/or delete operations. |
Sample main.tf
// Terraform OneFuse Provider
terraform {
required_providers {
onefuse = {
source = "CloudBoltSoftware/onefuse"
version = ">= 1.50.2"
}
}
required_version = ">= 0.13"
}
// Inititalize OneFuse Provider
provider "onefuse" {
scheme = var.onefuse_scheme
address = var.onefuse_address
port = var.onefuse_port
user = var.onefuse_user
password = var.onefuse_password
verify_ssl = var.onefuse_verify_ssl
}
// Data Source for vRealize Automation Policy - lookup Policy ID by Policy Name
data "onefuse_vra_policy" "vra_policy" {
name = "my_policy_name" // Replace with Policy Name
}
// Resource for vRealize Automation
resource "onefuse_vra_deployment" "my_vra_deployment" {
policy_id = data.onefuse_vra_policy.vra_policy.id // Refers to Data Source to get Policy ID
workspace_url = var.workspace_url
template_properties = var.template_properties
deployment_name = "tf_vra_deployment"
timeouts {
create = "20m"
delete = "20m"
}
}
// Outputs for Resource
output "vra_deployment_response" {
value = onefuse_vra_deployment.my_vra_deployment.deployment_info
}
OneFuse Module: VMware Aria Automation import
Create main.tf for VMware Aria Automation resource import
Add the following in the main.tf file.
The following parameter is required to import the VMware Aria Automation object.
Parameters:
| Parameter name | Required? | Notes |
|---|---|---|
policy_id |
Required | OneFuse Module Policy ID (integer). |
Sample main.tf
// Terraform OneFuse Provider
terraform {
required_providers {
onefuse = {
source = "CloudBoltSoftware/onefuse"
version = ">= 1.50.2"
}
}
required_version = ">= 0.13"
}
// Inititalize OneFuse Provider
// Create the separate variables.tf file or hard code the values.
provider "onefuse" {
scheme = var.onefuse_scheme
address = var.onefuse_address
port = var.onefuse_port
user = var.onefuse_user
password = var.onefuse_password
verify_ssl = var.onefuse_verify_ssl
}
resource "onefuse_vra_deployment" "my_vra_deployment" {
policy_id = 1
}
Run the following command to import the OneFuse VMware Aria Automation resource:
terraform import <resource_type>.<resource_name> <resource_id>
terraform import onefuse_vra_deployment.my_vra_deployment 2