Question regarding variables

26 views
Skip to first unread message

llo...@oreillyauto.com

unread,
Jun 7, 2012, 10:14:13 AM6/7/12
to puppet...@googlegroups.com
I am using puppet 2.7.14

I have a class that I use just to define a bunch of variables used by my module, several of them used in more than once place.

Currently I have it in module/manifests/classes/module_vars.pp

In some of the other classes, I was able to use the variables by qualifying the name - module::module_vars::var

However, I am having trouble getting these variables to show up in my templates.

First I just tried using the plain name, then I tried using

scope.lookupvar(module_vars::var)
scope.lookupvar(module::module_vars::var)

but all that shows up in my template is "undefined".

I've looked through the documentation, but I can't figure out what I am doing wrong.

Thank you.

Garrett Honeycutt

unread,
Jun 7, 2012, 11:03:10 AM6/7/12
to puppet...@googlegroups.com, llo...@oreillyauto.com
One method would be to bring them into the local scope.

class foo {

$var = $variables::var
}

then in your template you could use

<%= var %>


Two issues I spotted though. Your path setup is not correct for the
auto-loader. Suggested reading -
http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html

Also, check out Hiera -
http://puppetlabs.com/blog/first-look-installing-and-using-hiera/

-g

--
Garrett Honeycutt

206.414.8658
http://puppetlabs.com

earthgecko

unread,
Jun 8, 2012, 9:15:22 AM6/8/12
to Puppet Users
Possibly the templates in question are being evaluated before the
module_vars.pp Check the master log for something like:

"Could not look up qualified variable 'module::module_vars::var';
class module has not been evaluated"

G
Reply all
Reply to author
Forward
0 new messages