-
Notifications
You must be signed in to change notification settings - Fork 33
Modify read deployment to read all the properties of the resource #40
Conversation
61ac9ce
to
505cf27
Compare
This PR is addressing the following open issues:
What will change? Before:
After:
The above modification in the TF config file will result in the following tf state file. "resource_configuration" is a list of all the VM data read from vra. This includes ip_address, host_name, etc. It also shows all 3 VMs (including 2 VMs of vSphere1 type as the specified cluster size is 2). This same state will be generated on importing an existing deployment as well.
An example to output ip_addresses:
This results in the following:
Taking the discussion in #41 further. Binaries: Linux Mac/Darwin Windows Example:
|
505cf27
to
d1ea0ff
Compare
@Prativa20 It looks almost perfect. There is just one small problem that I don't know how to resolve. I usually run the provisioners in modules that I can reuse from different providers. The modules are usually different for each of the resource_configuration. This means that I need to call the module for each resource_configuration only with the IP addresses for that configuration. I couldn't figure out how to do that. I tried something like this, but it's not accepted: In addition, the module will also need the count of the VM for the resource_configuration. How can it be obtained? Thanks in advance. |
Hi @GMZwinge I haven't tried it yet but I believe we can make use of terraform conditional operators https://www.hashicorp.com/blog/terraform-0-12-conditional-operator-improvements/ Something like, If we can translate this logic to use these conditional operators. Thanks, |
Hi, Any ideas? Thanks |
How is this PR coming? My organization is very interested in Terraform being able to return all the VRA values of all VMs as we are integrating with Hashicorp Sentinel for policy validation. |
Hi, we are also waiting for this issue to be resolved as without getting all properties like IP the provider and terraform as well is almost unusable for our scenario. |
Hi @Prativa20 thanks for maintaining vra7 provider. I've managed to deploy infrastructure using vra7 provider from this PR on VMware vRealize Automation 7.6. Uncommenting lifecycle block in vra7_deployment resource, makes code idempotent at the expense of making further customization.
|
Hi, Thanks |
@moogster post your code so we can take a look. |
The following used to work in a remote-exec with terraform v0.12.5 and provider.vra7 v0.5.0 If I use that with terraform v0.12.21 and a beta vra provider, I get the following error: Block type " resource_configuration" is represented by a set of objects, and set elements do not have addressable keys. To find elements matching specific criteria, use a "for" expression with an "if" clause. Thanks |
f30550d
to
d973230
Compare
d973230
to
4a0b51e
Compare
17d524c
to
b1dd8da
Compare
00b0f44
to
3e93759
Compare
3e93759
to
a46f167
Compare
a955652
to
f02e408
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks real good. Thank you for taking on this big update! There are some doc changes necessary but approving in advance of those changes.
f02e408
to
f94c917
Compare
1. Addressing the following issues: https://github.com/terraform-providers/terraform-provider-vra7/issues/55 https://github.com/terraform-providers/terraform-provider-vra7/issues/54 https://github.com/terraform-providers/terraform-provider-vra7/issues/47 https://github.com/terraform-providers/terraform-provider-vra7/issues/43 https://github.com/terraform-providers/terraform-provider-vra7/issues/41 https://github.com/terraform-providers/terraform-provider-vra7/issues/39 https://github.com/terraform-providers/terraform-provider-vra7/issues/38 https://github.com/terraform-providers/terraform-provider-vra7/issues/33 https://github.com/terraform-providers/terraform-provider-vra7/issues/29 https://github.com/terraform-providers/terraform-provider-vra7/issues/27 https://github.com/terraform-providers/terraform-provider-vra7/issues/16 2. Re-designed the resource_configuration schema to include more properties 3. Implemented Day 2 operations for Scale In and Scale Out and Change Lease 4. Added import functionality 5. Added vra7_deployment data source 6. Updated the create and update logic as per the new schema 7. Modify read deployment to read all the properties retuned from the API 8. Modified README.md, examples and documentation as per the new schema Signed-off-by: Prativa Bawri <[email protected]>
f94c917
to
799d2d2
Compare
I pulled down v1.0.0 and tested. It is working wonderfully. Love the new features like day2 scaling, ability to call multiple components in same deployment, and returning all resource values to tfstate. |
Hi, I'm just getting a chance to test this now, I am getting an authentication error:
My config looks like this. I am still on TF v0.11 as i was getting the parallel-provisioning issue with 0.12. Is it possible that this fixes that? (I can look up the issue #'s if necessary)
|
@t-settle Thanks for the feedback :) Please open new issues if you find any. |
@mcascone Regarding the authentication error, if the creds are correct, it should not throw this error. Can you please attach the vra-terraform.log file. Also, we do not validate SSL certificates, so add insecure=true if any certificate errors. The config file looks fine except one change that you can do, although it will not make any difference at this point unless you try scaling day 2 operations. Remove _cluster from configuration block and add a cluster property as follows. resource_configuration { For the parallel-provisioning issue, it would be great if you can provide the issue that you are talking about. |
Terraform log is at https://gist.github.com/mcascone/ce21c1f654992f90a8f37137ed730712 Where does the The parallel provision issue is here, and it is pretty much blocking everything for me: hashicorp/terraform#22722 |
@mcascone From the logs, it seems that fetching the business groups for this tenant is throwing this error. insecure will go in the provider block. I am not sure about the parallel provisioning issue. I will look into it and update. |
@Prativa20, i updated the gist with the full debug log of the issue i'm seeing: https://gist.github.com/mcascone/ce21c1f654992f90a8f37137ed730712 (actual cloud URL redacted in the logs) Any insight on the parallel issue? |
@mcascone The request to get subtenants/business groups for the tenant 'Engineering' is throwing 403. Please check your vRA administration setup. To unblock, you can try the following: Let me know if that works for you. |
Hi, thanks so much for your quick action on all this. Removing the business group name does make the request go though! Now, i've progressed to the next error... I don't know if this is a driver issue or an issue with my org's vRA instance:
I am still on TF 0.11 due to the parallel issue mentioned above.
Update: it was indeed an issue with our vCenter config. Our admin tweaked it - i don't know what the change was - and now it works! |
With a configuration as follows, how do i get the IP and Name? I can't come up with a valid output line. Will it not work with TF v0.11? resource "vra7_deployment" "TF-Deploy-Windows" {
count = 2
description = "Terraform Deploy ${count.index + 1}"
catalog_item_name = "${var.vra_windows_cat_item_name}"
wait_timeout = "2000"
lease_days = 7
resource_configuration {
component_name = "vSphere__vCenter__Machine_1"
cluster = 1
configuration = {
cpu = 2
memory = 4096
description = "Terraform Windows Machine ${count.index + 1}"
}
}
}
# note: i can not come up with a version of this syntax that passes validation
output "Windows Machine Names" {
value = ["${vra7_deployment.TF-Deploy-Windows.*.resource_configuration.*.name}"]
} State file:
|
Try putting your splat in brackets:
|
Thanks @t-settle, i did try that without success, but i believe that is 0.12 syntax, and I'm on 0.11. There is a separate issue in 0.12 that blocks me from upgrading - although i haven't tried in a while, so maybe i'll update the syntax to 0.12 and try it all again. |
so, i haven't updated to v0.12 syntax yet, but i have made a bit of progress and hit another wall. With this output configuration, i get the following:
The
However I can not create the syntax to pull out just the name or IP. Or even the cluster, at the very top of the map. Any further additions to the output line either fail syntax or give no output. What am I doing wrong? Whenever i try to put the * in brackets, i get |
Alright, i got it. I upgraded to v0.12, and this simple statement does it:
|
Another wall: in the This: I'll try the provisioning in a |
Sorry mixed the reference see issue #65 |
Signed-off-by: Prativa Bawri [email protected]