We have been using te the hostgroup for while with hiera, first we had a just a simple
Searchpath of
%{hostgroup}
And this would do something sensible and look in for a particular host
parent_group/middle_group/child_group.yaml
on the filesystem.
We have just started adding extra facts,
hostgroup_0=parent_group
hostgroup_1=middle_group
hostgroup_2=child_group
…
And have a hiera search path of
…
%{hostgroup_0}/%{hostgroup_1}/%{hostgroup_2}/%{hostgroup_3}
%{hostgroup_0}/%{hostgroup_1}/%{hostgroup_2}
%{hostgroup_0}/%{hostgroup_1}
%{hostgroup_0}
The result of course is that
parent_group.yaml
Works for all hosts with
parent_group/middle_group.yaml providing overrides. Even if the are no hosts in middle_group and only in child_group.
Genrally doing anything based on the child_group is not good without its context, we have lots of hostgroup tips called e.g "server".
···
Sam Kottler wrote:+1 to _.
I read through the Hiera code to see how they handle it, and AFAICT, this isn’t ever a situation that you can encounter with Hiera because it does a hierarchal lookup for a specific value, but never actually has to return the environment (or subsequently tree) that it looked up before returning the value. I may be missing something, but I’ve never queried Hiera for the key, only the value for a particular host.
This is obviously a breaking change, so it requires some care. Maybe it’s best to make this a setting and have it default to the way it works right now? That might add some unnecessary complication to the hostgroup architecture, though.
-Sam
Sam Kottler
** Please do not send sensitive information without GPG. **
GPG key: 1566309E
IRC: samkottler on irc.freenode.nethttp://irc.freenode.net (feel free to PM without a ping)
On Jul 7, 2012, at 12:24 PM, Brian Gupta wrote:
On Sat, Jul 7, 2012 at 11:13 AM, Sam Kottler <sam@kottlerdevelopment.commailto:sam@kottlerdevelopment.com> wrote:
I ran into an interesting problem this morning and want to gather feedback
before I submit a pull request to make this change.
When you have a hostgroup that has a parent, its fact value is <parent
/. This creates problems when you are trying to use the
hostgroup fact inside a manifest because file names with slashes in them are
invalid (unless they are unicode encoded). This invalidates a use case like:
In order fix this issue, I propose that the value of $hostgroup should only
be the name of the child group if there is a parent. The disadvantage of
this is the potential for namespace conflicts if you have two parent groups
that have children with the same name.
Thoughts?
Hmmm two thoughts?:
- What about parenthostgroup_childhostgroup??
- How does Hiera handle this?
In any case, what would this break if we were to change this
behaviour? IE: Are people relying on the current behavior for
anything?
-Brian
Sam Kottler
** Please do not send sensitive information without GPG. **
GPG key: 1566309E
IRC: samkottler on irc.freenode.nethttp://irc.freenode.net (feel free to PM without a ping)
–
You received this message because you are subscribed to the Google Groups “Foreman users” group.
To post to this group, send email to foreman-users@googlegroups.commailto:foreman-users@googlegroups.com.
To unsubscribe from this group, send email to foreman-users+unsubscribe@googlegroups.commailto:foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/foreman-users?hl=en.