Skip to content

Instantly share code, notes, and snippets.

@Farzy
Created April 6, 2015 17:21
Show Gist options
  • Save Farzy/378a38872d850c4a73fe to your computer and use it in GitHub Desktop.
Save Farzy/378a38872d850c4a73fe to your computer and use it in GitHub Desktop.
Puppet define config_file
# Define a config file than can be an usual source, or a template URL: template:///
define config_file($path = false, $source = false, $mode, $owner, $group) {
file {"$title":
mode => $mode,
owner => $owner,
group => $group,
}
if $path {
File["$title"]{
path => $path,
}
}
if $source {
$prot = regsubst($source,'^([a-z]+):///(.*)', '\1')
if $prot == 'puppet' {
File["$title"]{
source => $source,
}
}
elsif $prot == 'template' {
$template = regsubst($source,'^([a-z]+):///(.*)', '\2')
File["$title"]{
content => template($template),
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment