Trying to create VMs in foreman using terraform with customization (original) (raw)
I am creating multiple vms in foreman using terraform with some customization however while running terraform apply it gives error.
Error: Unsupported argument
on main.tf line 33, in resource “foreman_host” “vms”:
33: location_id = each.value[“LOCATION_ID”]
An argument named “location_id” is not expected here.
Also unable to pass compute attributes as it tells
Error: “compute_attributes” contains an invalid JSON: invalid character ‘C’ after object key:value pair
Below is my main.tf file. I am using provider terraform-coop/foreman/0.7.0
==============================================
locals {
csv_data = file(“${path.module}/vms.csv”)
vm_metadata = csvdecode(local.csv_data)
}
resource “foreman_host” “vms” {
for_each = { for vm_metadata in local.vm_metadata : vm_metadata.HOSTNAME => vm_metadata }
name = each.value[“HOSTNAME”]
hostgroup_id = each.value[“HOSTGROUP”]
managed = true
set_build_flag = true
location_id = each.value[“LOCATION_ID”]
compute_attributes = <<EOF
{
“cpus” : “each.value[“CPU”]”,
“memory_mb” : “each.value[“MEMORY”]”
}
EOF
}
How we can customize CPU/Memory/location/organization or does this not supported
I figured organization ID and location should be in foreman provider.
however still not able to customize CPU and Memory
if any one come across such scenario please let me know
%%%%
server_protocol = “https”
location_id = 2
organization_id = 1
%%%%%%%%
I was able to fix it. we can close it.