Skip to content
New issue

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

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

Already on GitHub? # to your account

vsphere_virtual_machine.vm does not have attribute 'default_ip_address' #402

Closed
den-is opened this issue Feb 16, 2018 · 14 comments
Closed
Labels
bug Type: Bug stale Status: Stale

Comments

@den-is
Copy link

den-is commented Feb 16, 2018

After upgrading vCenter from 5.5 to 6.5 some optional steps stopped working.
In this case terraform plan is trying to get VM IP before VM is actually created.

Versions

❯ terraform -v
Terraform v0.11.3
+ provider.vsphere v1.3.2

Affected Resource(s)

❯ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.vsphere_datacenter.dc: Refreshing state...
data.vsphere_resource_pool.rpool: Refreshing state...
data.vsphere_datastore.ds: Refreshing state...
data.vsphere_virtual_machine.template: Refreshing state...
data.vsphere_network.net: Refreshing state...
------------------------------------------------------------------------
Error: Error running plan: 1 error(s) occurred:
* module.tftest.output.ip_addresses: Resource 'vsphere_virtual_machine.vm' does not have attribute 'default_ip_address' for variable 'vsphere_virtual_machine.vm.*.default_ip_address'

outputs.tf

output "ip_addresses" {
 value = "${vsphere_virtual_machine.vm.*.default_ip_address}"
}
@vancluever
Copy link
Contributor

@den-is this is usually due to an error higher up the dependency chain. Can you try removing the output and planning again and see if you can plan successfully?

Thanks!

@den-is
Copy link
Author

den-is commented Feb 16, 2018

@vancluever yes of course when I'm removing it everything works fine.
I've created TF module which contains some default outputs declarations for future use.
with 5.5 it was working

@vancluever
Copy link
Contributor

vancluever commented Feb 16, 2018

@den-is - I think I see the error in your output actually:

module.tftest.output.ip_addresses: Resource 'vsphere_virtual_machine.vm' does not have attribute 'default_ip_address' for variable 'vsphere_virtual_machine.vm.*.default_ip_address'

The resource address implies that there is only one VM (ie: no count specified), so globbing with * won't work here. Try vsphere_virtual_machine.vm.default_ip_address.

@den-is
Copy link
Author

den-is commented Feb 16, 2018

hmmmm can't get it...
if what am I doing wrong
this is my module initialization:

module "tftest" {
  source           = "./vmwareprod"
  servers          = 2
  hostname_prefix  = "tftest"
  domain           = "int.example.com"
  template         = "template-centos-7.4"
  cluster          = "prod"
  datastore        = "VM_SATA_NFS_Linux_01"
  ipaddresses      = ["10.55.1.99", "10.55.1.100"]
  network          = "int"
  mask             = 23
  gateway          = "10.55.1.1"
  dns              = ["10.55.1.17", "10.55.1.18"]
}

module has this outputs declaration:

output "ip_addresses" {
 value = "${vsphere_virtual_machine.vm.*.default_ip_address}"
}

external to module outputs declaration, what user sees:

output "vm_IPs" {
  value = "${module.tftest.ip_addresses}"
}

there is count in module initialization, in this case 2 - doesn't work. same with when count is 1.

@kevinskim93
Copy link

kevinskim93 commented Feb 16, 2018

I am running into a similar issue. I am running

output "ip" { value = "${vsphere_virtual_machine.vm.default_ip_address}" }

and I am seeing


Error: Error running plan: 1 error(s) occurred:

* output.ip: Resource 'vsphere_virtual_machine.vm' does not have attribute 'default_ip_address' for variable 'vsphere_virtual_machine.vm.default_ip_address'

@vancluever vancluever added bug Type: Bug and removed question labels Feb 16, 2018
@vancluever
Copy link
Contributor

vancluever commented Feb 16, 2018

Hey @den-is and @kevinskim93, thanks for the input. I've changed this to a bug. I can't reproduce it over here with a basic configuration, unfortunately, so it might be hard to track down on this end.

I am going to attempt the upgrade path to see if it's easy to re-produce that way.

@astraios
Copy link

I have the same issue:

module.instance.output.ip: Resource 'vsphere_virtual_machine.instance' does not have attribute 'default_ip_address' for variable 'vsphere_virtual_machine.instance.default_ip_address'

I wrote myself a terraform module that create a vSphere VM.

I tested it with vSphere 6.0 and vSphere provider 1.3.2 and 1.3.3
terraform version is 0.11.5.

@dmilind
Copy link

dmilind commented Jun 13, 2018

I am getting same issue.
I have this block in .tf file
output "ip" { value = "${vsphere_virtual_machine.vm.*.default_ip_address}" }
error that I am getting is
Error: vsphere_virtual_machine.vm: vsphere_virtual_machine.vm: self reference not allowed: "vsphere_virtual_machine.vm.*.default_ip_address"
any clue ?

@422158
Copy link

422158 commented Mar 4, 2019

any progress on this... this bug is compromising our automated destroy of environments

@sholland
Copy link

Seeing this issue as well, anyway to make this a priority?

@spstratis
Copy link

Another issue that I think is related to this is that I'm not even able to run a remote-exec provisioner if the host IP is assigned by DHCP. It doesn't seem like I can actually access the default_ip_address from TF. Here is an example of my provisioner where I run into the issue...

  provisioner "remote-exec" {
    inline = [
      "sudo apt-get update -y",
      "sudo apt-get install -y nginx"
    ]

    connection {
      host = "${self.default_ip_address}"
      type = "ssh"
      user = "ubuntu"
      private_key = "${file("files/test-prod.pem")}"
    }
  }

@erickellerek1
Copy link

erickellerek1 commented Sep 10, 2019

@spstratis any hint about this issue? did you achieve to get the host ip in another way?
wait_for_guest_net_routable = true did the trick for me...

@hashibot
Copy link

This issue has been open 180 days with no activity. If this issue is reproducible with the latest version of the provider and with Terraform 0.12, please comment. Otherwise this issue will be closed in 30 days.

@hashibot hashibot added the stale Status: Stale label Apr 24, 2020
@ghost
Copy link

ghost commented Jun 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Jun 23, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Type: Bug stale Status: Stale
Projects
None yet
Development

No branches or pull requests

10 participants