Recently ran into some of these when running Puppet 2.7.x:
warning: Dynamic lookup of $variable is deprecated. Support will be removed in Puppet 2.8. Use a fully-qualified variable name (e.g., $classname::variable) or parameterized classes.
The solution was pretty obvious and it’s easy to fix because the solution is mentioned in the warning. However the warning fails to mention what to do with Facter facts inside ERB templates. Figuring out how to fix this took me quite a while although it’s easy too.
Let’s start by taking a look at this snippet:
NameVirtualHost <%= 'ipaddress' %>:80 < VirtualHost <%= 'ipaddress' %>:80 > Servername www.example.com DocumentRoot /var/www/vhosts/example.com ServerAdmin info@example.com
If we’d apply this template in a manifest using Puppet 2.7.x we would run into the warning mentioned above because the IP address fact is out of scope. In order to avoid this we use lookupvar for Facter facts:
NameVirtualHost <%= scope.lookupvar('ipaddress') %>:80 < VirtualHost <%= scope.lookupvar('ipaddress') %>:80 > Servername www.example.com DocumentRoot /var/www/vhosts/example.com ServerAdmin info@example.com
For a fact I believe you need : to prefix the fact with ::
ex :
otherwise you still get :
Use a fully-qualified variable name (e.g., $classname::variable) or parameterized classes.
Facter facts are defined in the top-level scope. So you’re able to use $::ipaddress, too.
Saz
Please ignore my last comment. It’s wrong. You were talking about ERB templates.
Saz