Terraform-VMWare-Modules / terraform-vsphere-vm

Terraform vSphere module for provisioning Virtual Machines
https://registry.terraform.io/modules/Terraform-VMWare-Modules/vm/vsphere/
MIT License
167 stars 176 forks source link

Support for multiple cardinality for tagging a virtual machine #159

Open RDG88 opened 6 months ago

RDG88 commented 6 months ago

I'm attempting to assign multiple tags within the same category to a virtual machine but encountering an issue where only one tag is successfully added. Here's how I've structured the tags:

i defined the tags like this:

tags = {
    "cat-ansible" = "ssh_key"
    "cat-ansible" = "update_round_1"
  }

It seems that only one tag specified is being applied.

Hello-User commented 4 months ago

I ran into the same issue. A workaround I settled for is just importing the vsphere tag manually,

data "vsphere_tag_category" "iac" {
  provider      = vsphere
  name = "IaC"
}

data "vsphere_tag" "terraform" {
  provider      = vsphere
  name = "Terraform"
  category_id = data.vsphere_tag_category.iac.id
}

data "vsphere_tag" "ansible" {
  provider      = vsphere
  name = "Ansible"
  category_id = data.vsphere_tag_category.iac.id
}

And defining tag_ids in my vm declaration. tag_ids = [ data.vsphere_tag.ansible.id, data.vsphere_tag.terraform.id ]