On Mon, Feb 7, 2011 at 11:46 PM, Joe Gross <jgr...@stimpy.net> wrote:
> Hi all,
>
> I'm new to puppet put did a lot with cfengine2 at my last gig. I'm using
> v0.25.4 (default) on Ubuntu Lucid but can upgrade to 2.6 if necessary.
>
> I have a few hundred (with more on the way) machines in a new datacenter. I
> have about a dozen classes of hosts, designated by <dc>-<function><n>, so
> for example:
>
> sjc-web29
> sjc-db35
> sjc-smtp3
>
> My nodes.pp is super-simple this way:
>
> node default {
>   include dsh
>   include getty
>   include grub
>   include ntp
>   include postfix
>   include ssh
>   include sudo
> }
>
> This worked really well in cfengine, allowing me to keep decisions
> self-contained within individual modules. I'm trying to do the same with
> puppet without any luck so far. Ideally I'd do something like:
>
> $role = inline_template("<%= %x{/bin/hostname | /bin/sed -re
> 's/.*\-(\w+)[0-9]/\1/g'} %>")
> tag("type_${role}")

You realize this will execute on the master, and thus use the master
hostname rather than the node?

>
> And then do if tagged("role_smtp") within the modules. This keeps my high
> level simple in that I just call modules and they do the right thing.
>
> The problem is this doesn't seem to work. It seems that $role and the tags
> never get set, even if I try to set them manually so I'm clearly doing
> something fundamentally wrong.
>
> Has anyone done this type of setup where all the decisions are made within
> the modules themselves based on parts of a hostname or tags? I'm happy to
> provide more information or post more bits of my config if needed.

This is actually my favorite way of doing things. A single default
node that includes a single module "base" which then decides which
other modules to include.

This does work best if you distribute custom facts that provide more
abstracted semantics about roles though. Otherwise you end up with
spaghetti Puppet code like you've started with above :)

Say you distribute a custom fact "role", it then becomes as simple as:

class base {

  if $role == "foo" { include foo }

}

Or if you absolutely know you have a one to one mapping between
modules and roles, just "include $foo", but in my experience you
usually want a little more logic involved than that.



>
> Thanks!
>
> Joe
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet-users@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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@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