/terraform-provider-ansible

community terraform provider for ansible

Primary LanguageGo

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:

Requirements

Installation to Terraform

  1. Clone this repository to any location on your computer (or download source code)
  2. 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.