I have a terraform project that provisions a complex infrastrucure that comprehends a node that acts as a ansible control node.
Is there a way to trigger the execution of an ansible playbook on the remote control node, after that the apply command has finished executing?
I watched the Terraform talk where they talk about integrating ansible in the terraform flow but they use remote-exec provisioner to trigger the playbook in the remote machine itself, which is a useless use case in a serious prod environment.
I want to execute the playbook after the terraform apply for two reasons:
- I want to make sure that the whole infrastructure has been completely deployed otherwise it could fail for obivious reasons.
It looks like they didn't think about that, since the
remote-execgets executed as soon as the instance gets created. - since I'm inferring the ansible inventory from the terraform state I need the environment to be completely deployed (btw I'm inferring the state in a very hacky way)
Also I'd like some advice on how to load the ansible playbooks into the remote control node after the apply, in there a best practice? Thank you!