No description
  • Go 95.5%
  • Go Template 3%
  • HCL 0.9%
  • Shell 0.4%
  • Makefile 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Mostafa Mahmoud 81500f2d24
feat(inventory): add custom variables to host block (#166)
* feat(inventory): add custom variables to host block

* chore(docs): fix typos and add vars example in data-source example

* refactor(inventory): fix lint errors

* test: add tests for inventory data source

* refactor(inventory): implement custom marshaller logic directly in hostToJson

* feat(inventory): warn on host variable conflicts

* test(inventory): remove acc from inventory test name
2026-07-15 08:19:47 +02:00
.github chore(ci): bump dependencies (#162) 2026-06-11 08:36:00 +02:00
changelogs Prepare for release 1.5.0 (#164) 2026-06-17 08:18:15 +02:00
docs feat(inventory): add custom variables to host block (#166) 2026-07-15 08:19:47 +02:00
examples feat(inventory): add custom variables to host block (#166) 2026-07-15 08:19:47 +02:00
framework feat(inventory): add custom variables to host block (#166) 2026-07-15 08:19:47 +02:00
provider chore(deps): update Go version to 1.26 and bump dependencies (#157) 2026-05-28 17:01:04 +02:00
providerutils perf: preallocate slices with known capacity (#159) 2026-05-27 07:21:20 +02:00
templates feat(vault): add ansible_vault data sources and ephemeral resources (#156) 2026-06-04 09:29:15 +02:00
tests feat: Support complex types in ansible_host and ansible_group variables 2026-02-09 13:05:19 +01:00
tools add underscore as described into documentation 2023-03-17 15:34:25 +01:00
.gitignore Add log files and IDE folder to be ignored. 2023-01-20 12:17:11 +01:00
.golangci.yml chore(deps): update Go version to 1.26 and bump dependencies (#157) 2026-05-28 17:01:04 +02:00
.goreleaser.yml Update to goreleaser config version 2 (#153) 2026-03-03 15:24:39 -05:00
CHANGELOG.rst Prepare for release 1.5.0 (#164) 2026-06-17 08:18:15 +02:00
go.mod feat(vault): add ansible_vault data sources and ephemeral resources (#156) 2026-06-04 09:29:15 +02:00
go.sum feat(vault): add ansible_vault data sources and ephemeral resources (#156) 2026-06-04 09:29:15 +02:00
LICENSE Add GPLv3 licensing 2023-07-05 15:01:59 +02:00
main.go Add playbook action (#146) 2025-12-12 15:00:03 +01:00
Makefile test(framework): bootstrap unit and acceptance test infrastructure (#158) 2026-05-29 11:58:27 +02:00
README.md test(framework): bootstrap unit and acceptance test infrastructure (#158) 2026-05-29 11:58:27 +02:00
terraform-registry-manifest.json Prepare release 2023-03-17 14:56:41 +01:00

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 for Local Development

Run make. This will build a terraform-provider-ansible binary in the top level of the project. To get Terraform to use this binary, configure the development overrides for the provider installation. The easiest way to do this will be to create a config file with the following contents:

provider_installation {
  dev_overrides {
    "ansible/ansible" = "/path/to/project/root"
  }

  direct {}
}

The /path/to/project/root should point to the location where you have cloned this repo, where the terraform-provider-ansible binary will be built. You can then set the TF_CLI_CONFIG_FILE environment variable to point to this config file, and Terraform will use the provider binary you just built.

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
make tests

# GH actions locally
./act

Examples

The examples subdirectory contains a usage example for this provider.

Release notes

See the generated changelog.

Releasing

To release a new version of the provider:

  1. Update the version number in https://github.com/ansible/terraform-provider-ansible/blob/main/examples/provider/provider.tf
  2. Run go generate to regenerate docs
  3. Run antsibull-changelog release --version <version> to release a new version of the project.
  4. Commit changes
  5. Push a new tag (this should trigger an automated release process to the Terraform Registry)
  6. Verify the new version is published at https://registry.terraform.io/providers/ansible/ansible/latest

Licensing

GNU General Public License v3.0. See LICENSE for full text.