How to deal with servers roles

53 views
Skip to first unread message

Hugo Deprez

unread,
Jul 24, 2015, 12:11:15 PM7/24/15
to puppet...@googlegroups.com
Hello,

I am deploying a puppet server in order to manage a new infrastructure running Debian.
As I am starting from scratch, I'm looking for advice on how to deal with server roles.

I plan to create a class role::base with all default modules. So far no issues.

But I don't know how to properly deploy modules according to the server role. For exemple :

rsyslog configration : one server, all others  should be client.

I am thinking of doing the following :

# syslog-client  definition
node 'debian' inherits basenodeGLOBAL
{
         include role::base
         include role::syslog-client
}

# syslog server defintion

node 'debian2' inherits basenodeGLOBAL
{
         include role::base
         include role::syslog-server
}


but this mean that all my clients need to have the     include role::syslog-client statement...

How do you guys deal with this  ?

Rsyslog was just an example, I have the same issue with ntp module...

Regards

Hugo




Elisiano Petrini

unread,
Jul 25, 2015, 10:27:38 AM7/25/15
to Puppet Users, hugo....@gmail.com
A simple solution to this could be using hiera, but you need to have a parameter in the profile class (by the way, I believe you're mixing profiles with roles).

node 'debian'
{
    include role::syslogserver
}

node 'debian2'
{
   include role::myotherrole
}

then

class role::myotherrole {
    include profile::base
    # include other things
}

class role::syslogserver {
   $role='syslogserver'
   include profile::base
   # other stuff(?)
}

class profile::base {
    include profile::syslog
    #other base services
}

class profile::syslog ( $server=false ) {
   validate_bool($server) # this requires puppetlabs-stdlib
   if $server {
        # include server class
   } else {
        # include client class
   }
}

Now depending on your hiera configuration you can either leverage the role for the hierarchy path or the nodename (I'm not gonna go into details on how to configure hiera because there is plenty of documentation out there)
<snippet from hiera.yaml>
:hierarchy:
  - "node/${::fqdn}"
  - "role/${::role}"
  -  common
</snippet>

then in <hieradatadir>/role/syslog.yaml
profile::syslog::server: true


Please forgive me if there are any mistakes in the above, it's been a long time since I did classification like this (now we're using an ENC and json as backend, not yaml). Hopefully you get the idea.
We successfully use the same strategy for smtp, syslog and other services.

Best Regards,
    Elisiano Petrini
Reply all
Reply to author
Forward
0 new messages