Host with multiple host groups

Is it possible to assign multiple host groups to a host?

Right now I am using nested host groups (parent -> child) but am finding
that it is not meeting my needs. In particular I am ending up with hundreds
of host groups.

Ideally I have a set of base host groups for each site that my servers can
sit in (ie: US1, HK1, SY1, etc). These host groups define things such at
the location, capsule, puppet master and puppet ca, compute resource, etc
(and maybe some additional parameters).

I then have specific server roles (ie: activemq or webserver). These host
groups would define puppet classes, OS and compute profiles.

The way I have it worked now is that I have to create a nested host group
for each role in each site (ie: US1/activemq, HK1/activemq, etc).

Is there a way to accomplish what I am trying without having to define
hundreds of hostgroups?

Thanks

>
> Is it possible to assign multiple host groups to a host?
>
> Right now I am using nested host groups (parent -> child) but am finding
that it is not meeting my needs. In particular I am ending up with hundreds
of host groups.
>
> Ideally I have a set of base host groups for each site that my servers
can sit in (ie: US1, HK1, SY1, etc). These host groups define things such
at the location, capsule, puppet master and puppet ca, compute resource,
etc (and maybe some additional parameters).
>
> I then have specific server roles (ie: activemq or webserver). These host
groups would define puppet classes, OS and compute profiles.
>
> The way I have it worked now is that I have to create a nested host group
for each role in each site (ie: US1/activemq, HK1/activemq, etc).
>
> Is there a way to accomplish what I am trying without having to define
hundreds of hostgroups?

Not entirely no, but some of it yes.

Hosts can only have one host group - that's been a principle of Foreman
from it's very early days. Much of this stems from the difficulty of
handling conflicts - if two hostgroups specifing an OS are applied to a
host, which one wins? The same question applies to almost every
single-value field in the host form (subnet, installation media, puppet
master, all parameter values, and so on).

However, you can apply multiple config groups to hosts. These are much
simpler objects, and only contain puppet classes, but a host can have as
many as you like. Note though, so that parameters don't clash, you can't
apply paramteres to classes this way - you'd want to use the matchers
system on the class edit page for anything complex there (or something
external like Hiera).

You can also look at the Locations and Organisations feature to handle your
geographical grouping - this may further help you simplify the hostgroup
structure.

Hope that helps,
Greg

··· On 28 December 2015 at 23:37, Matthew Ceroni wrote:

> Is it possible to assign multiple host groups to a host?

In short, no. But that might not be what you need.

> Ideally I have a set of base host groups for each site that my servers can
> sit in (ie: US1, HK1, SY1, etc). These host groups define things such at
> the location, capsule, puppet master and puppet ca, compute resource, etc
> (and maybe some additional parameters).

Up to this point all good. Just 1 thing, if things like puppet master
etc… are specific per location, why not setting them on the Location
instead of setting them on Hostgroup?

> I then have specific server roles (ie: activemq or webserver). These host
> groups would define puppet classes, OS and compute profiles.

Have you looked at config groups (configure > Puppet > config groups)?
They allow you to group puppet classes to be applied to a host/host
group.

I realize for these specific roles, to set the OS and compute profile you'
d still need host groups.

> The way I have it worked now is that I have to create a nested host group
> for each role in each site (ie: US1/activemq, HK1/activemq, etc).

That sounds sane, no? Imagine you could have multiple inheritance
(activemq inherits from US1 & HK1) - what puppet master is applied to
activemq, etc…?

> Is there a way to accomplish what I am trying without having to define
> hundreds of hostgroups?

I don't think so, config groups might help though. Setting multiple host
groups to a host sounds a bit problematic because of the conflict
resolution between host group properties.

··· On 12/28, Matthew Ceroni wrote:


Daniel Lobato Garcia

@dLobatog
blog.daniellobato.me
daniellobato.me

GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30
Keybase: https://keybase.io/elobato

Answers below.

>
> > Is it possible to assign multiple host groups to a host?
>
> In short, no. But that might not be what you need.
>
> > Ideally I have a set of base host groups for each site that my servers
> can
> > sit in (ie: US1, HK1, SY1, etc). These host groups define things such at
> > the location, capsule, puppet master and puppet ca, compute resource,
> etc
> > (and maybe some additional parameters).
>
> Up to this point all good. Just 1 thing, if things like puppet master
> etc… are specific per location, why not setting them on the Location
> instead of setting them on Hostgroup?
>

I looked into this. How can I set puppet master, puppet ca, capsule (since
I am using Katello) and compute resource on the location. Under the edit
Location page I can specify which smart proxies apply to a specific
location but when creating a new host that doesn't populate the Puppet
Master, CA, Capsule and compute resource drop down box.

I have been looking at a way to specify them via parameters on the location
page. Within a template you reference values like puppetmaster through the
@host.puppetmaster. Is there a way to set that via a straight parameter in
the Locations section?

If I could accomplish this it would solve almost all my issues.

>
> > I then have specific server roles (ie: activemq or webserver). These
> host
> > groups would define puppet classes, OS and compute profiles.
>
> Have you looked at config groups (configure > Puppet > config groups)?
> They allow you to group puppet classes to be applied to a host/host
> group.
>
> I realize for these specific roles, to set the OS and compute profile you'
> d still need host groups.
>

I have looked at config groups, but they are still tied to a specific host
group so don't think it solves much of what I am looking for.

>
> > The way I have it worked now is that I have to create a nested host
> group
> > for each role in each site (ie: US1/activemq, HK1/activemq, etc).
>
> That sounds sane, no? Imagine you could have multiple inheritance
> (activemq inherits from US1 & HK1) - what puppet master is applied to
> activemq, etc…?
>

Not following this. US1 and HK1 mutually exclusive so a role hostgroup (ie:
activemq) wouldn't inherit from both. Can you have multiple inheritance?
Such that I create one hostgroup activeMQ, another US1 and then inherit
from both of those to create a new hostgroup? That would essentially
accomplish assigning two hostgroups to one host.

··· On Tuesday, December 29, 2015 at 3:44:16 AM UTC-8, Daniel Lobato wrote: > On 12/28, Matthew Ceroni wrote:

Is there a way to accomplish what I am trying without having to define
hundreds of hostgroups?

I don’t think so, config groups might help though. Setting multiple host
groups to a host sounds a bit problematic because of the conflict
resolution between host group properties.


Daniel Lobato Garcia

@dLobatog
blog.daniellobato.me
daniellobato.me

GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30
Keybase: https://keybase.io/elobato

Ah gotcha. For some reason I thought we had those fields (PuppetCA,
Puppet Master, etc…) under Location/Organization as well. Mind to file
a RFE for that? Setting default options for a host once a Location is
selected sounds good to me
http://projects.theforeman.org/projects/foreman/issues/new

··· On 12/29, Matthew Ceroni wrote: > Answers below. > > On Tuesday, December 29, 2015 at 3:44:16 AM UTC-8, Daniel Lobato wrote: > > > > On 12/28, Matthew Ceroni wrote: > > > Is it possible to assign multiple host groups to a host? > > > > In short, no. But that might not be what you need. > > > > > Ideally I have a set of base host groups for each site that my servers > > can > > > sit in (ie: US1, HK1, SY1, etc). These host groups define things such at > > > the location, capsule, puppet master and puppet ca, compute resource, > > etc > > > (and maybe some additional parameters). > > > > Up to this point all good. Just 1 thing, if things like puppet master > > etc.. are specific per location, why not setting them on the Location > > instead of setting them on Hostgroup? > > > > I looked into this. How can I set puppet master, puppet ca, capsule (since > I am using Katello) and compute resource on the location. Under the edit > Location page I can specify which smart proxies apply to a specific > location but when creating a new host that doesn't populate the Puppet > Master, CA, Capsule and compute resource drop down box. > > I have been looking at a way to specify them via parameters on the location > page. Within a template you reference values like puppetmaster through the > @host.puppetmaster. Is there a way to set that via a straight parameter in > the Locations section? > > If I could accomplish this it would solve almost all my issues.


Daniel Lobato Garcia

@dLobatog
blog.daniellobato.me
daniellobato.me

GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30
Keybase: https://keybase.io/elobato

Ok. I will open a RFE.

So no way to work around that right now I guess?

··· On Wednesday, December 30, 2015 at 1:45:50 AM UTC-8, Daniel Lobato wrote: > > On 12/29, Matthew Ceroni wrote: > > Answers below. > > > > On Tuesday, December 29, 2015 at 3:44:16 AM UTC-8, Daniel Lobato wrote: > > > > > > On 12/28, Matthew Ceroni wrote: > > > > Is it possible to assign multiple host groups to a host? > > > > > > In short, no. But that might not be what you need. > > > > > > > Ideally I have a set of base host groups for each site that my > servers > > > can > > > > sit in (ie: US1, HK1, SY1, etc). These host groups define things > such at > > > > the location, capsule, puppet master and puppet ca, compute > resource, > > > etc > > > > (and maybe some additional parameters). > > > > > > Up to this point all good. Just 1 thing, if things like puppet master > > > etc.. are specific per location, why not setting them on the Location > > > instead of setting them on Hostgroup? > > > > > > > I looked into this. How can I set puppet master, puppet ca, capsule > (since > > I am using Katello) and compute resource on the location. Under the edit > > Location page I can specify which smart proxies apply to a specific > > location but when creating a new host that doesn't populate the Puppet > > Master, CA, Capsule and compute resource drop down box. > > > > I have been looking at a way to specify them via parameters on the > location > > page. Within a template you reference values like puppetmaster through > the > > @host.puppetmaster. Is there a way to set that via a straight parameter > in > > the Locations section? > > > > If I could accomplish this it would solve almost all my issues. > > Ah gotcha. For some reason I thought we had those fields (PuppetCA, > Puppet Master, etc..) under Location/Organization as well. Mind to file > a RFE for that? Setting default options for a host once a Location is > selected sounds good to me > http://projects.theforeman.org/projects/foreman/issues/new > > > -- > Daniel Lobato Garcia > > @dLobatog > blog.daniellobato.me > daniellobato.me > > GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30 > Keybase: https://keybase.io/elobato >

http://projects.theforeman.org/issues/12960

··· On Wednesday, December 30, 2015 at 9:04:22 AM UTC-8, Matthew Ceroni wrote: > > Ok. I will open a RFE. > > So no way to work around that right now I guess? > > On Wednesday, December 30, 2015 at 1:45:50 AM UTC-8, Daniel Lobato wrote: >> >> On 12/29, Matthew Ceroni wrote: >> > Answers below. >> > >> > On Tuesday, December 29, 2015 at 3:44:16 AM UTC-8, Daniel Lobato wrote: >> > > >> > > On 12/28, Matthew Ceroni wrote: >> > > > Is it possible to assign multiple host groups to a host? >> > > >> > > In short, no. But that might not be what you need. >> > > >> > > > Ideally I have a set of base host groups for each site that my >> servers >> > > can >> > > > sit in (ie: US1, HK1, SY1, etc). These host groups define things >> such at >> > > > the location, capsule, puppet master and puppet ca, compute >> resource, >> > > etc >> > > > (and maybe some additional parameters). >> > > >> > > Up to this point all good. Just 1 thing, if things like puppet master >> > > etc.. are specific per location, why not setting them on the Location >> > > instead of setting them on Hostgroup? >> > > >> > >> > I looked into this. How can I set puppet master, puppet ca, capsule >> (since >> > I am using Katello) and compute resource on the location. Under the >> edit >> > Location page I can specify which smart proxies apply to a specific >> > location but when creating a new host that doesn't populate the Puppet >> > Master, CA, Capsule and compute resource drop down box. >> > >> > I have been looking at a way to specify them via parameters on the >> location >> > page. Within a template you reference values like puppetmaster through >> the >> > @host.puppetmaster. Is there a way to set that via a straight parameter >> in >> > the Locations section? >> > >> > If I could accomplish this it would solve almost all my issues. >> >> Ah gotcha. For some reason I thought we had those fields (PuppetCA, >> Puppet Master, etc..) under Location/Organization as well. Mind to file >> a RFE for that? Setting default options for a host once a Location is >> selected sounds good to me >> http://projects.theforeman.org/projects/foreman/issues/new >> >> >> -- >> Daniel Lobato Garcia >> >> @dLobatog >> blog.daniellobato.me >> daniellobato.me >> >> GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30 >> Keybase: https://keybase.io/elobato >> >