My default template directory is
# sudo puppet config print templatedir
/var/lib/puppet/templates
While my modulepath is
# sudo puppet config print modulepath --section master
/etc/puppet/modules:/usr/share/puppet/modules
How do I make template directory relative to module path? i.e. something like /etc/puppet/modules/module_name/template
P.S. I googled it, did not find relevant result. Kindly help.
You can use the template
function to return a string using your modulepath https://docs.puppet.com/puppet/latest/function.html#template. If you wanted to reference a template in /etc/puppet/modules/module_name/templates
, then you could do template(module_name/template.erb)
. If you wanted to use an .epp
template instead of .erb
, then you can use the epp
function https://docs.puppet.com/puppet/latest/function.html#epp.
Since the content
attribute (https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content) of the the file
resource accepts strings, you can use the string return value of these two functions in your file
resources like so:
file { '/path/to/file':
ensure => file,
content => template('module_name/template.erb'),
}
file { '/path/to/file':
ensure => file,
content => epp('module_name/template.epp'),
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments