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

creating a vsphere_vapp_entity for VMs, created with a count loop, requires two terraform apply runs #2141

Open
4 tasks done
erSitzt opened this issue Mar 5, 2024 · 2 comments
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage

Comments

@erSitzt
Copy link

erSitzt commented Mar 5, 2024

Community Guidelines

  • I have read and agree to the HashiCorp Community Guidelines .
  • Vote on this issue by adding a 👍 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

1.7.4

Terraform Provider

v2.6.1

VMware vSphere

v7.0.3

Description

The vsphere_vapp_entity settings are only created/set for a single VM in the loop. Maybe the first completed... not sure.
A second run is needed to apply the settings for all VMs.

Affected Resources or Data Sources

resource/vsphere_vapp_entity

Terraform Configuration

This is my config. I create several (k8s-server-/k8s-agent-) VMs using a count loop.

resource "vsphere_vapp_entity" "vapp-entity-server-nodes" {
  for_each = { for idx, moid in vsphere_virtual_machine.rke-server-nodes.*.moid : idx => {"moid" = moid} }
  target_id    = each.value.moid
  container_id = "${vsphere_vapp_container.vapp_container.id}"
  start_action = "powerOn"
  stop_action  = "guestShutdown"
  start_order = 1
  start_delay = 30
  stop_delay = 30

  depends_on = [ vsphere_virtual_machine.rke-server-nodes ]
}

resource "vsphere_vapp_entity" "vapp-entity-agent-nodes" {
  for_each = { for idx, moid in vsphere_virtual_machine.rke-agent-nodes.*.moid : idx => {"moid" = moid} }
  target_id    = each.value.moid
  container_id = "${vsphere_vapp_container.vapp_container.id}"
  start_action = "powerOn"
  stop_action  = "guestShutdown"
  start_order = 2
  start_delay = 30
  stop_delay = 30

  depends_on = [ vsphere_virtual_machine.rke-agent-nodes ]
}

resource "vsphere_vapp_entity" "vapp-entity-rke-lb" {
  target_id    = "${vsphere_virtual_machine.rke-lb.moid}"
  container_id = "${vsphere_vapp_container.vapp_container.id}"
  start_action = "powerOn"
  stop_action  = "guestShutdown"
  start_order = 1
  start_delay = 30
  stop_delay = 30

  depends_on = [ vsphere_virtual_machine.rke-lb ]
}

Debug Output

I have removed everything after the vsphere provider exited..
https://gist.github.com/erSitzt/166b721cdad2605cab740269304996b5

Panic Output

No response

Expected Behavior

All settings in one go..

Actual Behavior

Two runs necessary to finish the configuration

Steps to Reproduce

Create vsphere_vapp_entity for a bunch of VMs created by using count

Environment Details

❯ terraform version
Terraform v1.7.4
on linux_amd64
+ provider registry.terraform.io/gitlabhq/gitlab v16.5.0
+ provider registry.terraform.io/hashicorp/dns v3.4.0
+ provider registry.terraform.io/hashicorp/external v2.3.3
+ provider registry.terraform.io/hashicorp/helm v2.12.1
+ provider registry.terraform.io/hashicorp/kubernetes v2.26.0
+ provider registry.terraform.io/hashicorp/local v2.4.1
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/hashicorp/time v0.10.0
+ provider registry.terraform.io/hashicorp/vsphere v2.6.1
+ provider registry.terraform.io/rancher/rancher2 v3.1.1
+ provider registry.terraform.io/salrashid123/http-full v1.3.1

Screenshots

No response

References

No response

@erSitzt erSitzt added bug Type: Bug needs-triage Status: Issue Needs Triage labels Mar 5, 2024
Copy link

github-actions bot commented Mar 5, 2024

Hello, erSitzt! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

@erSitzt
Copy link
Author

erSitzt commented May 22, 2024

Still an issue

❯ terraform version
Terraform v1.8.3
on linux_amd64
+ provider registry.terraform.io/gitlabhq/gitlab v16.5.0
+ provider registry.terraform.io/hashicorp/external v2.3.3
+ provider registry.terraform.io/hashicorp/helm v2.13.2
+ provider registry.terraform.io/hashicorp/kubernetes v2.30.0
+ provider registry.terraform.io/hashicorp/local v2.5.1
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/hashicorp/time v0.11.1
+ provider registry.terraform.io/hashicorp/vault v4.2.0
+ provider registry.terraform.io/hashicorp/vsphere v2.8.1
+ provider registry.terraform.io/rancher/rancher2 v3.1.1
+ provider registry.terraform.io/salrashid123/http-full v1.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Projects
None yet
Development

No branches or pull requests

1 participant