Here's my situation: I've got two groups of machines, one where I have root
access and one where I don't (don't ask...).  The class to provide
particular functionality for a machine where I have root access ends up
looking a lot different than the class for when I don't.  The question is
how to organize this.

One option is just to put a big if { } else { } block in each class, which
does work, but feels ugly to me, which lead me to this idea.

In my module's manifest/init.pp, I have:

import "common/*.pp"

# $id is the user id of the person running puppet... so root in one case and
my regular user in the other

case $id {
  "root": {
     warning("including root...")
     import "root/*.pp"
   }
   "onebus": {
     warning("including onebus...")
     import "onebus/*.pp"
   }
}

I then have a root/someclass.pp and a onebus/someclass.pp, both of which
declare the someclass class (they both have same name).

I was hoping the case statement would selectively include the appropriate
class definitions (as a sanity check, I only see one "including ..." warning
in the logs, as hoped).  However, it seems like the import statements are
executing regardless and both versions of someclass are being included,
(warning debug messages in both the class definitions fire) which obviously
doesn't help me.

I'm curious why the above doesn't work.  I'll probably go back to individual
case statements within the classes themselves.

Is there some way to pull this off with class inheritance perhaps?

Thanks,
Brian
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Reply via email to