Should the hostgroup fact contain only the child's name if there's a parent?

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 group>/<child group>. 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?

··· ___ Sam Kottler ** Please do not send sensitive information without GPG. ** GPG key: 1566309E IRC: samkottler on irc.freenode.net (feel free to PM without a ping)

> 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
> >/<child group>. 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:
>
> https://gist.github.com/d1e4b9517a619a064ec6
>
> 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?:

  1. What about parenthostgroup_childhostgroup??
  2. 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

··· On Sat, Jul 7, 2012 at 11:13 AM, Sam Kottler wrote: > ___ > Sam Kottler > ** Please do not send sensitive information without GPG. ** > GPG key: 1566309E > IRC: samkottler on irc.freenode.net (feel free to PM without a ping) >

+1 to <parent group>_<child group>.

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.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.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:

https://gist.github.com/d1e4b9517a619a064ec6

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?:

  1. What about parenthostgroup_childhostgroup??
  2. 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.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.com.
To unsubscribe from this group, send email to foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/foreman-users?hl=en.