I’ll start off by saying I’m really pretty new to Terraform. I’m hoping someone can help me understand the workflow of provisioning new VM’s on vsphere with Terraform and then using Ansible to perform some initial configuration on the new machines. Here is where I am:
I can provision new VM’s using the vsphere provider and feeding it a listing of all the VM’s and their details that I want it to manage using the for_each meta argument in the resource block. The outcome of this is a simple, domain-joined Windows VM that can be connected to via Ansible using a local_exec provisioner.
The issue I’m having now is how do I get a list names of the VM’s that the latest terraform apply has created and and a list it has destroyed? I want to run an ansible configuration playbook on the new machines, as well as another ansible cleanup playbook for systems it has destroyed (removing DNS entries, registrations etc)?