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

Unable to use vSphere tags #142

Open
chryzsh opened this issue Mar 3, 2020 · 0 comments
Open

Unable to use vSphere tags #142

chryzsh opened this issue Mar 3, 2020 · 0 comments

Comments

@chryzsh
Copy link

chryzsh commented Mar 3, 2020

I tried to create a basic example for this in my vSphere lab. I've applied the tf state below and the host is running.

When I run my test playbook as follows, the group is not matched
ansible-playbook --inventory-file=terraform-inventory ../ansible/ubuntu_test.yml -u ubuntu

Output

PLAY [foo_bar] **************************************************************************************************************************************************************
skipping: no hosts matched

I took a look at #123 and I had the impression the correct syntax would be {tag-category}_{tag-name} which led me to believe that for my example that would be foo_bar, but alas. I also tried category_bar and category_tag, but the result is the same.

Could you please look into this or tell me where I'm going wrong?

Files:
ubuntu_test.yml

- hosts: foo_bar
  tasks:
*snip*

main.tf

resource "vsphere_tag_category" "category" {
  name        = "foo"
  cardinality = "SINGLE"
  description = "Managed by Terraform"

  associable_types = [
    "VirtualMachine"
  ]
}

resource "vsphere_tag" "tag" {
  name        = "bar"
  category_id = vsphere_tag_category.category.id
  description = "Managed by Terraform"
}

# Creating the resource 
resource "vsphere_virtual_machine" "ubuntu-test" {
  name             = "ubuntu-test"
  resource_pool_id = data.vsphere_resource_pool.pool.id
  datastore_id     = data.vsphere_datastore.datastore.id

  num_cpus = 2
  memory   = 4096
  guest_id = data.vsphere_virtual_machine.ubuntu-template.guest_id
  
  scsi_type = data.vsphere_virtual_machine.ubuntu-template.scsi_type

  network_interface {
    network_id = data.vsphere_network.network.id
  }

  disk {
    label = "disk0"
    size  = 60
  }

  folder = "terraform"

  tags = ["${vsphere_tag.tag.id}"]
clone {
    template_uuid = data.vsphere_virtual_machine.ubuntu-template.id

     customize {
      linux_options {
        host_name = "ubuntu-test"
        domain    = "lab.local"
        time_zone = "Europe/Oslo"
      }

      dns_server_list = ["192.168.0.1"]

      network_interface {
        ipv4_address = "192.168.0.51"
        ipv4_netmask = 24
      }

      ipv4_gateway = "192.168.0.1"
      
    }
  }
}
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