-
Notifications
You must be signed in to change notification settings - Fork 323
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
Adding better support for groups via the metadata.groups attribute #21
Conversation
@jackspirou I've tried compiling from your fork, with no avail:
./terraform-inventory --list still shows the hosts separate |
@vasiliyb can you send me an example file your using? Do you have a |
@jackspirou email sent, thank you! I dont see metadata.groups in --list output |
Hello! Thanks very much for your patch. However, I also can't seem to get it to work. None of the resources in my state files seem to include a |
Hi @vasiliyb and @adammck, sorry for the delay in responding. So the reason I submitted this was because our team needed something that Ansible groups could easily pickup. This PR takes the approach of adding a resource "openstack_compute_instance_v2" "hive" {
count = "${lookup(var.instances, var.env)}"
security_groups = ["default", "HTTP"]
name = "${var.env}-hive-${count.index}"
region = "${var.region}"
image_name = "${module.settings.images}"
flavor_name = "${lookup(var.flavor, var.env)}"
key_pair = "${module.settings.key_pair}"
floating_ip = "${lookup(var.static_address, var.env)}"
network {
name = "${module.settings.private_net}"
}
metadata {
groups = "web,api,hive"
}
} After using {"api":["10.65.82.170"],"hive":["10.65.82.170"],"web":["10.65.82.170"]} So values like {
"mongoc":["10.10.10.101","10.10.10.102","10.10.10.103"],
"mongos":["10.10.10.101","10.10.10.102","10.10.10.103"],
"mongosc":["10.10.10.101","10.10.10.102","10.10.10.103"],
"server.0":["10.10.10.101"],
"server.1":["10.10.10.102"],
"server.2":["10.10.10.103"]
} Let me know your thoughts and if this still makes sense given PR #22 or if we can consider #16 fixed. |
After taking a look at PR #22 I think it accomplishes much of this, but from what I understand it doesn't allow for multiple resources to one group, or multiple resources to multiple groups. So for example, you might have a shared Ansible bootstrap play to set default configuration on all servers belonging to the Again all feedback welcome. |
Thanks for getting back to me, @jackspirou. You're right that #22 doesn't provide arbitrary group names, which is something I'd very much like to add. I wasn't familiar with the metadata attribute, because (as far as I can tell), it's only supported by the OpenStack provider. But most other providers have their own mechanism (e.g. AWS's instance tags) for this sort of thing. I refactored master a bit already (to make this sort of thing simpler in future), and will try to get this merged shortly. Thanks very much for the patch! |
This PR has conflicts. Closing. |
This pull request adds better support for groups, via the
metadata.groups
attribute and fixes #16