Created
April 6, 2015 17:21
-
-
Save Farzy/378a38872d850c4a73fe to your computer and use it in GitHub Desktop.
Puppet define config_file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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