terraform-inventory icon indicating copy to clipboard operation
terraform-inventory copied to clipboard

inventory_hostname from Terraform resource name

Open bentinata opened this issue 6 years ago • 1 comments

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?

bentinata avatar Aug 26 '19 09:08 bentinata

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

cacack avatar Jun 02 '20 14:06 cacack