Hi ,

On 06 May 2016, at 17:29, Jeff <joesi...@gmail.com> wrote:

> I'm working on a puppet module that automatically places the entire catalog 
> into zenoss (this is based on an outdated module that I found on github)
> 
> By default, I want to place every server in zenoss. 
> 
> I have a base class which is included in every node. I want to add 'include 
> zenoss::client' in that class. 
> 
> node "server.jeff.com" {
>   include base  # this includes zenoss::client
> }
> 
> Now I'd like to be able to override that at the node level. Unfortunately, I 
> can't think of a slick way to do that without using a global. Something like:
> 
> node "server.jeff.com" {
>   $zensure = "absent"   # then I can use this global in base to switch ensure 
> to absent
>   include base  # this includes zenoss::client
> }
> 
> 
> I'm sure there's a better way to do this. Any thoughts?
> 

Solution 1: parametrised class and hiera

1. make your zenoss module class a parameterised class:

class zenoss (
  $enable = true,
){
  validate_bool($enable)
  if $enable {
    # this is your zenoss code
  }
}

2. enable hiera
put zenoss::enable key into hiera on a node specific level.

Solution 2: custom facts

put a custom fact onto the system which should not get zenoss:

/etc/puppetlabs/facter/facts.d/zenoss.txt
zenoss_disable = false

Within your zenoss module class: check for the ::zenoss_disable fact

zenoss {
  if ! $::zenoss_disable {
    # your zenoss module code
  }
}

A general advise:
do not put variables into node level
don’t put logic into node level.

hth,
Martin

> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/f42ed9a7-d1e2-4313-95fc-2d74afade11e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/6D92323D-D286-480C-9CBF-22170141A71C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to