Exinferis <der.aaron.koe...@googlemail.com> writes:

> Is that somehow possible with puppet?

Role-based configuration is possible with puppet.  The selection of
available roles will have to be preconfigured, but it is possible.

Instead of selecting on the registered host name you select on the role
it reports to have.

You will need to make a "role" fact, and you need to use a selector
within the default node definition, or with a matching wildcard node
definition:

,----[ server_role ]
| # role.rb
| Facter.add("role") do
|   setcode do
|     begin
|       file = File.new("/etc/role", "r")
|       line = file.gets
|       line.chomp
|     rescue => err
|       "undefined"
|     end
|   end
| end
`----

This allows for config like:

,----
| node default {
|     case $server_role {
|         'desktop': {
|             include my::desktop::class
|             include my::other::things
|         }
|     }
| }
`----

You should also be able to list multiple roles.  If you specify roles in
your file like this:

:one:two:three:desktop:whohooo:mission_critical:

you can match on:

,----
| node *.desktops.example.org {
|     case $server_role {
|         /:desktop:/ { include my::desktop::class }
|         /:mission_critical:/ { include corp::absolutely::vital:class }
|         /:whohooo:/ { include rubber::ducky }
|     }
| }
`----

...of course, I don't see that anyone would have absolutely vital stuff
on a desktop, but you get the picture. :)


Note: This will not remove things installed by other roles, if you
switch roles.  Your classes will have to fix that.  If one role installs
"apache HTTPD", your other roles would have to know about this, and
remove it.  This is not specific to role-based configuration.

-- 
Stig Sandbeck Mathisen
(fnord)

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