adammck / terraform-inventory

Terraform State → Ansible Dynamic Inventory
MIT License
1.82k stars 321 forks source link

inventory_hostname from Terraform resource name #124

Open bentinata opened 5 years ago

bentinata commented 5 years ago

Currently, any resource is written as single group in inventory.

For example, this Terraform:

resource "aws_instance" "my_instance" {
  ami           = data.aws_ami.ubuntu.id
  instance_type = "t2.micro"
}

Would yield:

[my_instance]
127.0.1.1
# or whatever the ip address is

I think, having it as:

my_instance ansible_host=127.0.1.1

would be better since we can refer to inventory_hostname from inside the playbook.

I haven't dive into the source code yet. I might want to make a pull request if this is desirable. Thoughts?

cacack commented 4 years ago

I like this idea, just for the improved readability of the Ansible output.