Puppet lets you set all caps variables in the manifest that you couldnt use in a template:
$FOO = "bar"
notice "from puppet: ${FOO}"
notice inline_template("<%= FOO %>")
Output is:
notice: Scope(Class[main]): from puppet: bar Failed to parse inline template: uninitialized constant Puppet::Parser::TemplateWrapper::FOO at /home/rip/test.pp:4 on node nephilim.ml.org
Not sure if you can make the template not handle those as constants, but if not then the language shouldn't let us make all caps variables.
You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account
This issue was assigned to a former Puppet Labs employee. Adding back to the pool of unreviewed issues.
This is absolutely still a bug in 2.7.9.
[root@centos5-64 foo]# cat manifests/init.pp
class foo {
$FOO = "Hello World"
file { "/tmp/output":
ensure => present,
mode => 0600,
content => template('foo/test.erb'),
}
}
[root@centos5-64 foo]# cat templates/test.erb
<%= FOO %>
[root@centos5-64 foo]# puppet apply --verbose --modulepath=.. -e 'include foo'
Failed to parse template foo/test.erb: uninitialized constant Puppet::Parser::TemplateWrapper::FOO at /root/module/foo/manifests/init.pp:9 on node centos5-64.localdomain
[root@centos5-64 foo]#
I’m not sure we should support this. my recommended fix would be to not allow all cap variables in manifests.
Ok, so the course of action is to not allow ALLCAPS variables in the Puppet DSL.
Michael Stahnke wrote:
Ok, so the course of action is to not allow ALLCAPS variables in the Puppet DSL.
Actually, I think they should be available in the new style in templates:
⚡ puppet apply -e '$FOO = "bar" notice(inline_template("[<%= @FOO %>]"))'
The member variable style avoids the collision with Ruby constants.