Page 1 of 1

Use multiple host templates to assign multiple host groups

Posted: Wed Mar 29, 2017 10:45 am
by gmackey
Linux Distribution and version? CentOS 6
32 or 64bit? 64-bit
VMware Image or Manual Install of XI? VMware image
Are there special configurations on your system, ie; is Gnome installed? Are you using a proxy? Are you using SSL? Using SSL

Hello! I've run into an issue with host templates and I'm hoping there's something I'm missing. My apologies if this gets posted twice; I just submitted the post and gave it a minute and it didn't show up so I'm trying again.

What I'm trying to do:

I'm using multiple host templates for each host, each of which assigns one free variable and one hostgroup. For example, I have a host template called "env-prod" that assigns a custom "_ENVIRONMENT" free variable that's set to "Prod" and also assigns a hostgroup membership of "Server Environment - Prod". The free variables are needed for email notifications if you're wondering and they're working great.

The problem:

The above example works perfectly fine. The problem is when I assign the second host template. The free variable is assigned but only one hostgroup is assigned. Whichever host template is ordered at the top of the list of host templates for that host is the one that assigns the hostgroup. The other assigned hostgroups are ignored so the host only shows up in one hostgroup in the hostgroup summary and elsewhere. To clarify, the host ends up with multiple free variables but only one hostgroup.

The workaround:

I'd prefer to avoid having to add each host to multiple templates AND multiple hostgroups to work around this issue. I'm trying to make this process as easy as I can on my co-workers when they've adding new hosts. Is there any way to get this working like I want?

Thanks!

Re: Use multiple host templates to assign multiple host grou

Posted: Wed Mar 29, 2017 11:37 am
by avandemore
I'm having trouble understanding exactly what you are doing.

XI > Admin > System Profile > Download Profile

Please include the zip file in your response. You can PM myself or other support personnel if you have privacy concerns.

Re: Use multiple host templates to assign multiple host grou

Posted: Wed Mar 29, 2017 11:49 am
by gmackey
System profile is attached. Thanks!

Re: Use multiple host templates to assign multiple host grou

Posted: Wed Mar 29, 2017 2:37 pm
by tgriep
By default, the first template over writes the second template and so on and so on.
But, you can make the Hostgroup additive in your templates to get all of the hostgroups applied to the host through the templates by doing the following.
Exit your templates and click on the Manage Host Groups Button, on the bottom, click on the Plus Sign (+) on the bottom of the menu which will make that group additive.
When all of the templates are applied to the hosts, they will get all of the hostgroups applied to them from the additive feature.

Nagios gives preference to local variables instead of values inherited from templates. In most cases local variable values override those that are defined in templates. In some cases it makes sense to allow Nagios to use the values of inherited and local variables together.
This "additive inheritance" can be accomplished by prepending the local variable value with a plus sign (+). This features is only available for standard (non-custom) variables that contain string values.

Re: Use multiple host templates to assign multiple host grou

Posted: Wed Mar 29, 2017 2:45 pm
by gmackey
Thank you! This did the trick and now my hosts are showing up in multiple hostgroups. I appreciate the quick response.

Re: Use multiple host templates to assign multiple host grou

Posted: Wed Mar 29, 2017 2:57 pm
by tgriep
Your Welcome, glad it worked for you. I'll close and lock the post as solved, but if you have any other questions, please feel free to open a new post.