Grouping Servers

33 views
Skip to first unread message

AB

unread,
Dec 8, 2011, 10:47:11 AM12/8/11
to puppet...@googlegroups.com
I was hoping to get info on a best practise or potentially an aim for a best practise that puppet development is working towards.

I would like to group our servers so that I can use the files server to hand out files in a hierarchal order starting with hostname, groupname, default file. I would also like to set the groupname in node.pp.  So far I have tried this using custom facts but it does not seem to be consistent.  I have read some posts for people trying to use mcollective but at this point I am not using it.  What I want to try next is to build the puppetgroup.rb file under /usr/lib64/ruby/site_ruby/1.8/facter/ that sets the fact but my thinking is I will be setting the fact during the first run and hence the fact I need to control config files is not loaded and the default config will be loaded and I will have to wait till the second puppet run (in some cases this could break a server's function), for the new fact to be used.

Some examples to show how I am implemented

node.pp
**snip**
node 'puppetclient2' inherits default {
        $group="deb"                     #set group for this server
        include puppetgroup           #setup fact for this server
        include nginx_conf             #apply an nginx.conf file to server, I use this method for iptables, sysctl.conf and etc_hosts
}
****

class puppetgroup.pp   #the sourcing of the new environment variable is inconsistent...sometimes it works and sometimes it doesn't,
******
class puppetgroup {
   Exec { path => "/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" }
        file {"/etc/profile.d/puppetgroup.sh":
        owner => root,
        group => root,
        mode  => 755,
        content => "export FACTER_puppetgroup=\"$group\"",

   }
   exec { "source puppetgroup": 
    subscribe   => File["/etc/profile.d/puppetgroup.sh"], 
    refreshonly => true, 
    command     => "bash -c 'source /etc/profile'", 
 } 
}
************

class nginx_conf  # Applying an nginx.conf depending on machine.
*****class nginx_conf {
file { "/opt/nginx/conf/nginx.conf":
            source   => [
                "puppet:///files/classes/nginx/nginx_conf.$hostname",
                "puppet:///files/classes/nginx/nginx_conf.$puppetgroup",
                "puppet:///files/classes/nginx/nginx_conf"
                ],
            mode     => "644",
            checksum => md5,
            replace => "yes",
            ensure  => "present",

    }
}
*******

Any thoughts on how to make this approach consistently happen?  Or a new approach that can do the same?  Can a force a reload of the facts at the end of running the puppetgroup.pp class?

Many thanks for any help.

Andre









AB

unread,
Dec 9, 2011, 11:43:04 AM12/9/11
to puppet...@googlegroups.com
No worries figured it out, just wasn't thinking outside the box.    Ended up getting rid of the fact or using facter and just using the variable straight away.

for others interest:

node.pp
$group="role"


source   => [
                "puppet:///files/classes/nginx/nginx_conf.$hostname",
                "puppet:///files/classes/nginx/nginx_conf.$group",
                "puppet:///files/classes/nginx/nginx_conf"
                ],

AB


Reply all
Reply to author
Forward
0 new messages