1
1
mirror of https://github.com/adammck/terraform-inventory synced 2024-11-22 20:01:58 +01:00
Terraform State → Ansible Dynamic Inventory
Go to file
Darian Moody 0bf40b4d72 Updated README
To state that currently this project only works with AWS Terraform resources.
2015-06-03 22:44:14 +01:00
fixtures Refactor to remove Terraform dependency 2015-02-09 16:37:30 -05:00
homebrew Add Homebrew formula 2015-02-09 16:51:45 -05:00
.gitignore Rename to terraform-inventory 2014-09-24 15:35:55 -04:00
cli_test.go Refactor to remove Terraform dependency 2015-02-09 16:37:30 -05:00
cli.go Add support for environment variables 2015-05-27 17:22:37 -05:00
main.go Add support for environment variables 2015-05-27 17:22:37 -05:00
parser_test.go Add support for environment variables 2015-05-27 17:22:37 -05:00
parser.go Add support for environment variables 2015-05-27 17:22:37 -05:00
README.md Updated README 2015-06-03 22:44:14 +01:00
version_test.go Add version info to binaries 2015-02-09 16:37:43 -05:00
version.go Add version info to binaries 2015-02-09 16:37:43 -05:00

Terraformed Inventory

This is a little Go app which generates an dynamic Ansible ansible inventory from an AWS-based [Terraform] tf state file. It allows one to spawn a bunch of EC2 VMs with Terraform, then (re-)provision them with Ansible. It's pretty neat.

Installation

On OSX, install it with Homebrew:

brew install https://raw.github.com/adammck/terraform-inventory/master/homebrew/terraform-inventory.rb

This is only a tiny tool, so it's not in the main Homebrew repo. Feel free to add it, if you think that would be useful.

Usage

Ansible doesn't (seem to) support calling the inventory script with parameters, so you can specify the path to the state file using the environment variable TI_TFSTATE like so:

TI_TFSTATE=deploy/terraform.tfstate ansible-playbook --inventory-file=terraform-inventory

Alternately, you can create a little shell script and call that. Something like:

#!/bin/bash
terraform-inventory $@ deploy/terraform.tfstate

Then run Ansible with the script as an inventory:

ansible-playbook --inventory-file=bin/inventory deploy/playbook.yml

Development

It's just a Go app, so the usual:

go get github.com/adammck/terraform-inventory
cd $GOPATH/adammck/terraform-inventory
go build

License

MIT.