berglh / antform

A command line/shell tool that converts terraform state files into ansible inventory files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

antform

Build Status

Despite it's name, antform is not a form markup language for our arthropodous friends, it is actually a command line tool written in Go that converts a terraform state file into an ansible inventory file.

The idea is to use terraform to deploy your infrastructure and then configure it with ansible using the inventory produced by antform. It has currently only been tested with the triton terraform provider, so your mileage may vary.

Usage

Arguments

Flag Example Description
-f /path/to/terraform.tfstate Specify the path to the terraform.tfstate file, defaults to current directory terraform.tfstate.
-t group Group the Terraform machines by tag, these exist in the attributes object and prefixed by tags.. This example would map to the key tags.group.

Switches

Flag Description
-h Displays the usage information.

Note: Currently antform outputs to stdout and assumess that your tfstate file is in the same structure as the test terraform.tfstate file in this repo. This solves the problem in my specific use case, but adding support for other terraform providers wouldn't be too dificult, however I haven't bothered to check if the provider structs are the same as triton so give it a go.

Examples

antform outputs the data in your tfstate file, sorting each primary ip address by name:

~$ antform
[es-data-1]
192.160.0.1
[es-data-2]
192.160.0.2
[es-data-3]
192.160.0.3

antform can then split the machines by tags that you define in the your terraform machine configuration:

~$ antform
[elasticsearch]
192.160.0.1
192.160.0.2
192.160.0.3

About

A command line/shell tool that converts terraform state files into ansible inventory files

License:MIT License


Languages

Language:Go 100.0%