[Puppet Users] Re: Scope object available functions and getting the local scope, or node scope variable values

2012-11-20 Thread jcbollinger


On Tuesday, November 20, 2012 1:34:23 AM UTC-6, Jayapandian Ponraj wrote:

 I have a node(b) inheriting another node(a). node(a) includes a class(c) 
 which inturn inherits class(d). I need to access the variable defined in 
 node (b) from class (d). I am not sure if its possible As far as i know 
 the node scope ends at node (a)Wat ll be the fully qualified name for 
 the variable in node(b)... My original question does not describe the 
 problem well, ignore it. 



Node variables do not have qualified names.  If they are not accessible via 
unqualified names in the local scope then they are not accessible at all.

On the other hand, in a node inheritance situation, the node variables of 
the parent node should be visible as node variables of the child node.

On the third hand, it is unwise to use node variables to modulate the 
behavior of your classes.  I recommend you avoid that.  There are a number 
of alternatives, but I can't recommend a particular one for your case with 
the limited information available to me.

Also, be very careful about class inheritance.  It probably doesn't do what 
you think it does, and it is rarely the best solution to a problem.  It's 
key and defining feature is the ability of subclasses to override 
parameters of resources declared by their superclasses.  If your reason for 
subclassing does not center on that feature then you do not need or want to 
subclass.  If the superclass is parametrized then you almost certainly do 
not want to subclass.  Until you understand what I have just written, you 
definitely do not want to subclass.


John

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/xh78Anj82O0J.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] Re: Scope object available functions and getting the local scope, or node scope variable values

2012-11-19 Thread jcbollinger


On Friday, November 16, 2012 6:30:43 AM UTC-6, Jayapandian Ponraj wrote:

 Is there a way to get the local scope values of puppet variables via 
 scope.? wat r all the available functions in scope? can anyone provide a 
 working example.


One normally accesses local-scope variables directly, rather than via the 
scope object:

$foo = 'bar'
# A stupid way to get the value of foo
$foo_copy = inline_template('%=@foo%')

Alternatively, you should be able to access any global or class variable 
via its fully-qualified name, including those from the local scope (if it 
is the top-level scope or a class scope).

I suspect that doesn't answer your real question though.  As Abhijeet 
asked, for what purpose do you want that?


John

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/dZAhLmTyUB4J.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.