Skip to content

Instantly share code, notes, and snippets.

@fatmcgav
Last active May 16, 2016 12:43
Show Gist options
  • Save fatmcgav/48d30a8a9b29d342035120528fec1767 to your computer and use it in GitHub Desktop.
Save fatmcgav/48d30a8a9b29d342035120528fec1767 to your computer and use it in GitHub Desktop.
Config_snippet defined type
define microservice::config_snippet(
$file = $title,
$module = $caller_module_name,
$order = 'nil',
$template = true
) {
# Validate params
validate_string($file)
validate_bool($template)
# Check order
case $order {
'nil': {
$split_title = split($title, '-')
$order_REAL = $split_title[0]
}
default: {
$order_REAL = $order
}
}
# Source from template?
$content = $template ? {
true => template("${module}/config/${file}"),
false => $content
}
# Source from file?
$source = $template ? {
true => undef,
false => "puppet:///modules/${module}/${file}"
}
# Create the concat::fragment resource
concat::fragment { $file:
content => $content,
order => $order_REAL,
target => $microservice::config_file,
source => $source
}
}
# vi:syntax=puppet:filetype=puppet:ts=4:et:
microservice::config_snippet { '50-config.txt.erb':
module => 'mod_a'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment