Skip to content

pieterlexis-tomtom/ansible-terraform-inventory

 
 

Repository files navigation

ansible-terraform-inventory

A dynamic inventory script for Ansible and Terraform.

Quickstart

To use this inventory script, you must first create Terraform resources using the terraform-provider-ansible plugin:

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

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

Next, use this script as your Ansible dynamic inventory script.

If your Ansible playbooks are in a different directory than your Terraform resources, then set the TF_STATE environment variable to the location of the Terraform directory.

Installation

Download the latest release.

Building From Source

$ go get github.com/jtopjian/ansible-terraform-inventory
$ go build -o $GOPATH/bin/terraform-inventory
$ ln -s $GOPATH/bin/terraform-inventory /path/to/ansible/hosts

About

Ansible Dynamic Inventory with Terraform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 91.0%
  • HCL 4.5%
  • Makefile 4.5%