radekg / terraform-provisioner-ansible

Ansible with Terraform 0.14.x
Apache License 2.0
572 stars 100 forks source link

add null_resource support #122

Closed stevestrutt closed 5 years ago

stevestrutt commented 5 years ago

Summary

Added support to allow terraform-provisioner-ansible to be used in local_mode with a null_resource. Target hosts for the provisioner can be specified using plays.hosts and interpolation from the ip_address of provisioned compute instances, or by passing an inventory file.

Included updates to Readme and an additional example.

Using terraform taint null_resource.xxxxxxx the provisioner can be triggered to run again on the next terraform apply.

Extensively tested on IBM Cloud. Operation will be the same across all cloud vendors.

Additional comment: I found when the provisioner is used with a compute resource, it is not necessary to specify a host in the connection block or with plays.hosts. If connection.host is not specified, Terraform passes the public IP address of the instance just created. This usage was not clear in the Readme.

radekg commented 5 years ago

Hi @stevestrutt. Thank you for the pull request. It looks complete. Being able to run Ansible via null_resource effectively turns Terraform into an Ansible runner.

I will run a couple of checks before merging.

radekg commented 5 years ago

Hi Steve, thank you once again for the contribution. I have merged your PR onto an intermediate branch to have the tests status covered. The intermediate PR is now merged to master. I will create a release mid next week, your changes will be in the new version.

Happy to hear this is extensively tested on the IBM Cloud!