Skip to content

Conversation

adammck
Copy link
Owner

@adammck adammck commented Dec 10, 2015

This is a little ugly, because the internal data structures weren't really designed for this. I didn't consider resources which use the count attribute to spawn multiple copies. But it works. When run against the updated tfstate fixture:

./terraform-inventory --list fixtures/example.tfstate | jq .

The output is:

{
  "web-aws": [
    "52.7.58.202",
    "52.91.51.56"
  ],
  "web-aws.0": [
    "52.7.58.202"
  ],
  "web-aws.1": [
    "52.91.51.56"
  ],
  "web-cs": [
    "10.2.1.5"
  ],
  "web-cs.0": [
    "10.2.1.5"
  ],
  "web-do": [
    "192.241.136.44"
  ],
  "web-do.0": [
    "192.241.136.44"
  ]
}

Note that resources are now accessible by their exact name, which includes the counter, and as a group by their base name, which does not. Feedback is very welcome.

Hopefully closes #16. It's currently unclear how this relates to #21, so that may well end up merged, too.

@adammck adammck mentioned this pull request Dec 10, 2015
@vasiliyb
Copy link

👍

adammck added a commit that referenced this pull request Dec 15, 2015
Add support for grouped count=n resources
@adammck adammck merged commit 6ccf619 into master Dec 15, 2015
@adammck adammck deleted the counted_instances branch December 15, 2015 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ansible HostGroup Support

2 participants