On Fri 26 Oct 2012 04:42:56 PM IST, Calvin Walton wrote:
On Fri, 2012-10-26 at 13:16 +0530, Abhijeet R wrote:
---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 %>


Sorry about using $a in templates. I actually wrote it by mistake and I didn't use it in my actual templates. But, I have a requirement where I've to use the values of $a, $b in other classes. Thing is like, some resources that are defined in user-defined resource have to defined only once and are common of two or more instances for defined resource. So, I included that in a new class (Otherwise, multiple definition errors come). Now, this class needs to use the values passed to defined resource. (ie $a, $b). So, what should I do? This thing is works in 2.6 and 2.7.9 perfectly but it throws errors like

For classes -> warning: Dynamic lookup of $node_id at /etc/puppet/modules/ucarp/manifests/up_down_scripts.pp:3 is deprecated. Support will be removed in Puppet 2.8. Use a fully-qualified variable name (e.g., $classname::variable) or parameterized classes.

For template -> warning: Dynamic lookup of $vip_addr_gw at /etc/puppet/modules/ucarp/templates/vip-up.erb:6 is deprecated. Support will be removed in Puppet 2.8. Use a fully-qualified variable name (e.g., $classname::variable) or parameterized classes.

If I think of making a parametrised class instead of user-defined resource, I'll be not be able to use that because I need to use that class more than once for a node. (That is why I actually used user-defined resource).

TLDR - Few resources of a defined resource are to be defined only once so are included in a class. How would that class be able to access the parameters passed to the user-defined resource? Also, this defined class is using templates to generate configuration files and needs to access the parameters passed to defined resource. How should that be done?

--
Cheers,
Abhijeet R
http://blog.abhijeetr.com

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
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.

Reply via email to