Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hostvars aren't being generated with hostname as keys #108

Open
queglay opened this issue Feb 24, 2019 · 2 comments
Open

hostvars aren't being generated with hostname as keys #108

queglay opened this issue Feb 24, 2019 · 2 comments

Comments

@queglay
Copy link

queglay commented Feb 24, 2019

Currently when I use terraform-inventory I get hostvars with keys by ip address. this is a problem because it means I cannot query hostvars by hostname, and ip adresses are not known for me to query. I would normally hope to be able to use hostvars to be able to query an ip address by host name.

Is it possible to change this behaviour to be able to define the keys better in the inventory/hostvars? normally in an inventory if the ip adress was prepended with the host name it would solve it I think.

ok: [localhost] => {
"hostvars": {
"13.210.124.113": {
"ami": "ami-05fdd828e5a7530b0",
"ansible_check_mode": false,
"ansible_diff_mode": false,
"ansible_facts": {},
"ansible_forks": 5,
"ansible_host": "13.210.241.143",
"ansible_inventory_sources": [
"/usr/local/bin/terraform-inventory"
],
"ansible_playbook_python": "/usr/bin/python",
"ansible_run_tags": [
"all"
],
"ansible_skip_tags": [],
"ansible_ssh_private_key_file": "~/my_key_pair.pem",
"ansible_verbosity": 0,
"ansible_version": {
"full": "2.7.8",

@queglay queglay changed the title hostvars aren't being generated with hostname hostvars aren't being generated with hostname as keys Feb 24, 2019
@susman
Copy link

susman commented Mar 26, 2019

there's TF_HOSTNAME_KEY_NAME env var available. we use terraform assigned "Name" tags as hostnames, then query ansible by that hostname with TF_HOSTNAME_KEY_NAME=tags.Name exported

@queglay
Copy link
Author

queglay commented Mar 26, 2019

I am using the tag "Name" in terraform when I create all AWS instances, and they are labelled correctly in AWS, but not listed as the key for the host's ip in the inventory. Should this label as the hostname be passed through to the inventory list normally? Currently I just get ip addresses and groups created with tags.

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

No branches or pull requests

2 participants