FAQ

On Fri, 2012-10-26 at 13:16 +0530, Abhijeet R wrote:
Hi all,

This may be a simple one but I am not able to do it.

Folder structure is like:

mname -> name of the module
---manifests
------init.pp -> includes class mname
------config.pp -> includes are user defined resource which is defined
as "define mname::config ( $a,$b ) { ... code here ... }
------misc.pp -> Contains misc class. This class is included in
config.pp. I did this because there are few resources which are to be
defined only once for a node if there are multiple user-defined
resources mname::config.pp defined. Now, in this class misc, I want to
access variable $a and $b. *How do I do that?* Using mname::config::a is
not working.. Error says "class config could not be found". This makes
sense because it's not a class, config is a user-defined resource type.
This doesn't make sense. Since mname::config is a defined resource, it
can be used multiple times. And each time, the values of $a and $b would
be different. How would the misc class know which values of $a and $b to
use if it's included from multiple mname::config instances?
---templates
------t1.erb -> I want to access value of $a and $b here. Using
mname::config::$a is not working. I am using <%=
scope.lookupvar("mname::config::$a" %> to get the value.
In templates, you don't use the $ character on variable names. If the
template is being used directly in the mname::config type, you can do
<%= @a %> (preferred)
or
<%= a %>

--
Calvin Walton <calvin.walton@kepstin.ca>

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 6 | next ›
Discussion Overview
grouppuppet-users @
categoriespuppet
postedOct 26, '12 at 8:47a
activeOct 26, '12 at 7:29p
posts6
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase