Skip to content

Instantly share code, notes, and snippets.

@jonhattan
Created March 28, 2013 17:47
Show Gist options
  • Save jonhattan/5265325 to your computer and use it in GitHub Desktop.
Save jonhattan/5265325 to your computer and use it in GitHub Desktop.
Pattern for creating non-homogeneous resource types in puppet from a hiera definition. Roundcube plugins as an use case. NOTE: filenames are intended to be a directory structure. Replace hypens with slashes.
class roundcube(
$dbprovider,
$dbuser = 'roundcube',
$dbpass = unset,
$dbname = 'roundcube') {
#...
$defaults = {
config => {},
}
$plugins = hiera_hash('roundcube::plugins')
create_resources(roundcube::plugin, $plugins, $defaults)
#...
}
define roundcube::plugin($config) {
if defined("roundcube::plugins::$name") {
$params = { "roundcube::plugins::$name" => $config }
create_resources('class', $params)
}
}
class roundcube::plugins::password(
$password_driver,
$password_confirm_current,
$password_minimum_length,
$password_require_nonalpha,
$password_log,
) {
file { '/etc/roundcube/plugins/password/config.inc.php':
ensure => present,
content => template('roundcube/plugins/password/config.inc.php.erb'),
}
}
roundcube::dbprovider : "mysql"
roundcube::dbpass : "secret"
roundcube::plugins:
compose_addressbook : {}
contextmenu : {}
listcommands : {}
quickrules : {}
sieverules : {}
vcard_attachments : {}
zipdownload : {}
password:
config:
password_driver : "sql"
password_confirm_current : true
password_minimum_length : 6
password_require_nonalpha : true
password_log : false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment