Need help with terraform-provider-ansible?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

290 Stars 49 Forks Mozilla Public License 2.0 90 Commits 4 Opened issues


"Logical" provider for integrating with an Ansible Dynamic Inventory script.

Services available


Need anything else?

Contributors list

# 70,442
78 commits
# 9,058
2 commits
# 10,547
1 commit

Ansible Terraform Provider

A Terraform provider serving as an interop layer for an Ansible dynamic inventory script.

Read the introductory blog post for an explanation of the design motivations behind this provider.


Installation can be accomplished in two different ways:

  1. For Terraform 0.13+ Use terraform required_providers block
  2. Installing a pre-compiled release (recommended)
  3. Compiling from source

For Terraform 0.13+ Use terraform required_providers block

terraform {
  required_providers {
    ansible = {
      source = "nbering/ansible"
      version = "1.0.4"
provider "ansible" {}
then perform another init to download the provider. ``` $ terraform init Initializing modules... Initializing the backend... Initializing provider plugins... - Finding nbering/ansible versions matching "1.0.4" ... - Installing nbering/ansible v1.0.4... - Installed nbering/ansible v1.0.4 (self-signed, key ID xxxxxxxxxxxxxx) ... Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. ```

Installing a Pre-Compiled Release

Downloading and installing a pre-compiled

release is the recommended method of installation since it requires no additional tools or libraries to be installed on your workstation.
  1. Visit the releases page and download the latest release for your target architecture.

  2. Unzip the downloaded file and copy the

    binary to a designated directory as described in Terraform's plugin installation instructions.

Compiling From Source

Note: Terraform requires Go 1.11 or later to successfully compile.

Note: Dependencies are no longer included in this repository. You may need the bazaar version control utility to download some of Terraform's Go-lang module dependencies.

If you'd like to take advantage of features not yet available in a pre-compiled release, you can compile

from source.

In order to compile, you will need to have Go installed on your workstation. Official instructions on how to install Go can be found here.

Alternatively, you can use gimme as a quick and easy way to install Go:

$ sudo wget -O /usr/local/bin/gimme
$ sudo chmod +x /usr/local/bin/gimme
$ gimme 1.10
# copy the output to your `.bashrc` and source `.bashrc`.

Once you have a working Go installation, you can compile

by doing the following:
$ go get
$ cd $GOPATH/src/
$ make

You should now have a

binary located at
. Copy this binary to a designated directory as described in Terraform's plugin installation instructions

Terraform Configuration Example

resource "ansible_host" "example" {
    inventory_hostname = ""
    groups = ["web"]
    vars = {
        ansible_user = "admin"

resource "ansible_group" "web" { inventory_group_name = "web" children = ["foo", "bar", "baz"] vars = { foo = "bar" bar = 2 } }


Version 1.0.0 of this project is compatible with Terraform version 0.12-beta2. You will also need 2.0.0+ of the terraform-inventory script, as the internal structure of Terraform state files has changed.

If you need a version compatible with an earlier version of Terraform, use version 0.0.4.

When upgrading to Terraform 0.12.x, you may need to change your configuration files to reflect changes to the new version of the Hashicorp Configuration Lanaguage (HCL). The only known incompatibility is that

attributes now require an equals operator (


resource "ansible_host" "example" {
    inventory_hostname = ""
    vars {
        ansible_user = "admin"


resource "ansible_host" "example" {
    inventory_hostname = ""
    vars = {
        ansible_user = "admin"

Alternatives and Similar Projects


A Terraform Provisioner that runs Ansible-Local on a target machine at creation-time.


A very similar solution to this one, without the Logical provider. Depends on specific Terraform resource types, and relies heavily on cloud-providers' tag implementations.

Ansible Module: Terraform

An Ansible module that runs Terraform plans and deployments.


Contributions specific to this project are made available under the Mozilla Public License.

Code under the

directory is copyright of the various package owners, and made available under their own license considerations.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.