Question

I have a best practice question around Puppet when working is server/agent mode.

I have created a working solution using a manifest/sites.pp configuration that identifies the configuration using the hostname of the agent.

For example:

node 'puppetagent.somedomain.com' {

        include my_module

        notify { 'agent configuration applied':
        }
}

This works great for configuring a single node but what if I had a scenario in which I had multiple applications servers all with differing hostnames but all of which needed the same configuration.

Adding multiple node entries, comma separated hostname list or regular expressions doesn't feel like the 'right' way to do this.

Are there alternative ways? Can you define node 'types'? What do the community consider best practice for this?

Many thanks

Was it helpful?

Solution

If all the servers have the same configuration, inheritance, or the hieara hierarchy are the easiest ways to achieve this.

Once you need to maintain a larger set of systems where certain nodes have types such as 'web server' or 'database server' the configurations will diverge and the single inheritance model is not entirely sufficient.

You can use composition in those places. Take a peak at this article for more details.

OTHER TIPS

Regular expressions might not be so bad, but I suppose the current trend is to use hiera_include.

You can do something dirty like this :

$roles = { 'webserver' => [ 'server1', 'server2', 'server3' ]
         , 'smtp'      => [ 'gw1', 'gw2' ]
         }
node default {
    $roles . filter |$k,$v| { $hostname in $v }
           . each |$k,$v| { hiera_include($k) }
}

I would suggest taking a look at the concept of "roles and profiles" here: http://www.craigdunn.org/2012/05/239/

You can have multiple nodes all of which include the same configuration with a "profile" that includes one or more "roles".

As for defining multiple nodes with the same configuration or a "profile" containing "role(s)", I would suggest using hiera_include like @bartavelle mentioned. Except to use a common environment variable for identifying the nodes rather than using regular expressions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top