Skip to content

pimsmath/ansible-terragrunt-inventory

 
 

Repository files navigation

ansible-terragrunt-inventory

A dynamic inventory script for Ansible and Terragrunt. This is a minor modification of ansible-terraform-inventory to use terragrunt in place of 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.

Set the TF_STATE environment variable to the directory which would contain the terraform.tfstate if the state was held locally.

Installation

Download the latest release.

Building From Source

$ go get github.com/pimsmath/ansible-terragrunt-inventory
$ go build -o $GOPATH/bin/terragrunt-inventory
$ ln -s $GOPATH/bin/terragrunt-inventory /path/to/ansible/inventory

About

Ansible Dynamic Inventory with Terraform

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 90.3%
  • Makefile 5.2%
  • HCL 4.5%