Open bitkeks opened 1 year ago
I am passing that using JSON encoding.
resource "foreman_host" "host" {
for_each = { for x in local.all_nodes : x.Name => x }
name = each.value.Name
build = true
domain_id = var.domain_id
compute_profile_id = can(each.value.computeprofile) ? module.globalresource[each.value.computeprofile] : var.compute_profile_id
compute_resource_id = var.compute_resource_id
hostgroup_id = can(each.value.hostgroup) ? module.globalresource[each.value.hostgroup] : var.hostgroup_id
image_id = can(each.value.image) ? module.globalresource[each.value.image] : var.image_id
operatingsystem_id = can(each.value.operatingsystem) ? module.globalresource[each.value.operatingsystem] : var.operatingsystem_id
compute_attributes = jsonencode({
cpus: can(each.value.CPUs) ? each.value.CPUs : null,
memory_mb: can(each.value.memory_gb) ? each.value.memory_gb * 1024 : null
})
model_id = 0
owner_id = 3
owner_type = "User"
retry_count = 2
interfaces_attributes {
type = "interface"
primary = true
provision = true
managed = true
ip = can(each.value.IP) ? each.value.IP : null
subnet_id = can(each.value.Network) ? module.globalresource[replace(each.value.Network, " Network", "")] : var.subnet_id
compute_attributes = {
"network" = can(each.value.Network) ? each.value.Network : var.network_id
"type" = "VirtualVmxnet3"
}
}
parameters = {
"puppet_environment" = var.puppetnenvironment
}
}
you can try this way you can manage subnet , network interface and even pass the static IP for new provision VM so that it can stick to that ip
When creating a Foreman host, the
interfaces_attributes
argument can be passed in to configure the network interfaces.At the moment, it seems to not be possible to set the order of the created interfaces. This might break scenarios in which the first interface is automatically the PXE-interface, but might not be the primary interface.
We will further investigate this issue.