Terraform Provider for Ansible
The Terraform Provider for Ansible provides a more straightforward and robust means of executing Ansible automation from Terraform than local-exec. Paired with the inventory plugin in the Ansible cloud.terraform collection, users can run Ansible playbooks and roles on infrastructure provisioned by Terraform. The provider also includes integrated ansible-vault support.
This provider can be found in the Terraform Registry here.
For more details on using Terraform and Ansible together see these blog posts:
- Terraforming clouds with Ansible
- Walking on Clouds with Ansible
- Providing Terraform with that Ansible Magic
Requirements
- install Go: official installation guide
- install Terraform: official installation guide
- install Ansible: official installation guide
Installation to Terraform
- Clone this repository to any location on your computer (or download source code)
- Use the command below from
<local-path-to-repository>/terraform-provider-ansible
make build-dev
Testing
Lint:
curl -L https://github.com/golangci/golangci-lint/releases/download/v1.50.1/golangci-lint-1.50.1-linux-amd64.tar.gz \
| tar --wildcards -xzf - --strip-components 1 "**/golangci-lint"
curl -L https://github.com/nektos/act/releases/download/v0.2.34/act_Linux_x86_64.tar.gz \
| tar -xzf - act
# linters
./golangci-lint run -v
# tests
cd tests/terraform_tests
./run_tftest.sh
# GH actions locally
./act
Examples
The examples subdirectory contains a usage example for this provider.