On 12/19/2013 12:39 PM, Josh wrote:
As we are starting to re-factor our puppet modules using Craig's
roles/profile design we have found that this system works well for
servers (or groups of servers) who have an entire stack of technology
deployed to them or who all are part the same custom application.
Clusters of servers typically have a unique set of configuration and fit
well into this design. For example, a web-server in the "app1" cluster
may look like:
node webserver1 {
include role::app1_webserver
}
class role::app1_webserver {
include profiles::base
include profiles::webserver:app1
}
class profiles::webserver::app1 {
class { '::apache':
a => 'x',
b => 'y',
}
file { "/etc/something":
ensure => present,
content => template("apache/blah.erb"),
}
}
Along with standard apache, there are various other custom/non-standard
things that need to be done. This works well in profiles because it
provides a layer of abstraction between the component modules and this
extra configuration is common for all servers in the "app1" cluster.
I'm having trouble understanding how to treat those "one-off" servers
who just need things like a standard apache, or a standard mysqld
installation, but aren't part of any common application and don't need
any custom stuff. I thought about defining profiles like so:
class profiles::webserver::apache::generic {
include ::apache
}
I feel like this design just over complicates the profiles logic, but I
can't seem to figure out another way to handle this type of scenario.
Furthermore, what if I need a generic webserver with PHP? Do I need
another profile (ie, profiles::webserver::apache::generic::php). Can
anyone give any input on to how I should be handling this?
Thanks,
Josh
You're overloading profile because you're not using Hiera or an ENC.
Take this example
class role::app1_fe { # or perhaps ::fe_app1
include profile::apache
include profile::php
}
class profile::apache {
include apache
$mymods = hiera('apache::a2mods', {})
create_resources('apache::a2mod', $mymods)
$myvhosts = hiera('apache::vhosts', {})
create_resources('apache::vhost', $myvhosts)
}
profile::apache can be used by *any* server that needs Apache because by
default it does nothing but the minimal config of Apache. However if you
were to feed it data such as modules to enable or vhosts to load you
could build any Apache server you might need.
hieradata/app1_fe.yaml # this assumes you have a role fact.
---
apache::a2mods:
expires: {}
headers: {}
rewrite: {}
apache::vhosts:
www.example.com: {}
Structures like profile::webserver::app1 indicate you're mixing roles
and profiles. And you also embedding data into your Puppet code rather
than writing code to consume data.
It's a lot to wrap your head around and from my experience it takes 1-2
restructures of your Puppet code to fully understand it.
Ramin
--
You received this message because you are subscribed to the Google Groups "Puppet
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/52B36A49.70407%40badapple.net.
For more options, visit https://groups.google.com/groups/opt_out.