Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Unable to edit attributes on template created without NIC configuration elements #68

Open
adarobin opened this issue Aug 21, 2023 · 0 comments

Comments

@adarobin
Copy link

Bug Description

I am not able to edit the attributes of an ome_template resource that did not have NIC configuration elements enabled. The template itself was created from an XML file exported from another instance of OpenManage Enterprise.

Resource or DataSource Name

ome_template

Terraform Version

1.5.4

go Version

n/a

OME Version

3.10.0 (Build 169)

Operating System

Linux

Terraform File Used

terraform {
  required_providers {
    ome = {
      source  = "dell/ome"
      version = ">= 1.0.0, < 2.0.0"
    }
  }
}

#use locals to modify the attributes required for updating a template using attribute ids.
locals {
  deployment_attributes = var.attributes_map != null ? [
    for attr in data.ome_template_info.main[local.deployment_template_name].attributes : tomap({
      attribute_id = attr.attribute_id
      is_ignored   = attr.is_ignored
      display_name = attr.display_name
      value        = lookup(var.attributes_map, attr.display_name, attr.value)
  })] : null

  compliance_attributes = var.attributes_map != null ? [
    for attr in data.ome_template_info.main[local.compliance_template_name].attributes : tomap({
      attribute_id = attr.attribute_id
      is_ignored   = attr.is_ignored
      display_name = attr.display_name
      value        = lookup(var.attributes_map, attr.display_name, attr.value)
  })] : null
  compliance_template_name = "${var.name} Compliance"
  deployment_template_name = "${var.name} Deployment"
}

resource "ome_template" "deployment" {
  name       = local.deployment_template_name
  content    = file("${path.module}/template.xml")
  view_type  = "Deployment"
  attributes = local.deployment_attributes
}

resource "ome_template" "compliance" {
  name       = local.compliance_template_name
  content    = file("${path.module}/template.xml")
  view_type  = "Compliance"
  attributes = local.compliance_attributes
}

data "ome_template_info" "main" {
  for_each = var.attributes_map == null ? [] : toset([local.compliance_template_name, local.deployment_template_name])

  name = each.key
}

variable "name" {
  type        = string
  description = "The name of the template."
}

variable "attributes_map" {
  type        = map(string)
  description = "A map of attributes to set in the template. The key is the attribute display name and the value is the attribute value. Do not set this until after the template has been created."
  default     = null
}


output "deployment_template_id" {
  description = "The ID of the deployment template"
  value       = ome_template.deployment.id
}

output "compliance_template_id" {
  description = "The ID of the compliance template"
  value       = ome_template.compliance.id
}

Logs

module.nsx_edge_template.ome_template.deployment: Modifying... [id=59]
module.nsx_edge_template.ome_template.compliance: Modifying... [id=60]
╷
│ Error: Unable to update template
│ 
│   with module.nsx_edge_template.ome_template.deployment,
│   on ../modules/bare_metal_edge_node_template/main.tf line 22, in resource "ome_template" "deployment":
│   22: resource "ome_template" "deployment" {
│ 
│ vlan attributes are not available in the template
╵
╷
│ Error: Unable to update template
│ 
│   with module.nsx_edge_template.ome_template.compliance,
│   on ../modules/bare_metal_edge_node_template/main.tf line 29, in resource "ome_template" "compliance":
│   29: resource "ome_template" "compliance" {
│ 
│ vlan attributes are not available in the template
╵

Error: Failed to perform terraform apply. Unexpected exit code: 1

Steps to Reproduce

Create the templates initially without the attributes_map variable set. This is successful.

Attempt to set a few values with the attributes_map variable after creation.

Expected Behavior

The terraform apply is successful.

Actual Behavior

The terraform apply fails.

Screenshots

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant