Site modules are usually private to an organization which is why there
might not be many published examples of them.
Writing a module that support the "site module" pattern is a bit
trickier but here's the most common use case I've found. A module
that is generally re-usable should use it's own template for the
general case but allow the module user to pass in a different template
from a different module. This "different module" is the site module.
So, how do I change the behavior of a module without modifying the
module itself? If it allows you to pass in the data you need then you
can store that data in a site module and pass it using the template
function:
# motd module:
class motd($motd_content='UNSET') {
$motd_content_real = $motd_content ? {
UNSET => template("motd/motd.erb"),
default => $motd_content,
}
# Manage the message of the day
file { "/etc/motd":
content => $motd_content_real,
}
}
Now there are two ways to use this module. If I don't want to change
the behavior I can just use it "as is"
node default { include motd }
However, if I want to change the message of the day I can pass in the
full contents from my own module rather than modifying the motd module
itself:
node default {
class { motd: motd_content => template('site/motd.erb') }
}
This will cause the motd module to use a template from my site module
rather than using it's own erb template. The key difference is
template("motd/motd.erb") inside the motd module versus
template("site/motd.erb") "outside" the motd module.
Hope this helps,
-Jeff