After reading masterzen’s excellent blog post about puppet storedconfigs, it gave me the idea to create a system of subscription to services.
For example, if you want some client to subscribe to a “backup” service you can use the following little things :
# Subscription system through exported resources
# A stupid idea of Nico <nico@gcu.info>
# $subscribedir is defined somewhere else
define set_subscription_to($title)
{
@@file { "$subscribedir/nodes/$title/$fqdn":
content => "\n",
tag => "$title"
}
define get_subscription_to($title)
{
file { "$subscribedir":
ensure => directory,
owner => root
}
file { "$subscribedir/nodes":
ensure => directory,
owner => root,
require => File["$subscribedir"]
}
file { "$subscribedir/nodes/$title":
ensure => directory,
owner => root,
require => File["$subscribedir/nodes"]
}
File <<| tag == $title |>>
}
and in your manifests :
class client {
set_subscription_to { "backup" : }
}
class server {
get_subscription_to { "backup": }
}
Then the server will be able to know which machines subscribed to something and then treat them by walking the associated folder ( $subscribedir/nodes/$title )
This can be really enhanced of course
Have fun