Hi all, I''m getting crazy with this... I have some templates where I use has_variable? with no problem. But now I have problems in new one. nods.pp node ''my_node'' { $CVMFS_mountpoint = "/mnt/cvmfs" $CVMFS_file = "/etc/auto.cvmfs" [...] include some_class_that_already_includes_autofs_class } [...] ''/etc/auto.master.test'': content => template(''computing_autofs/auto.master.erb''); [...] auto.master.erb /nfs file:/etc/auto.home -rw,hard,intr,tcp,async,rsize=32768,wsize=32768,timeo=600 <% if has_variable?("CVMFS_mountpoint") and has_variable?("CVMFS_file") %> <%= CVMFS_mountpoint %> <%= CVMFS_file %> <% end %> This gives : err: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template computing_autofs/auto.master.erb: uninitialized constant Puppet::Parser::TemplateWrapper::CVMFS_mountpoint at /etc/puppet/manifests/services/workernode/modules/computing_autofs/manifests/init.pp:35 If I change : <%= CVMFS_mountpoint %> <%= CVMFS_file %> for some static text (like KK), the templae works as expected: # cat /etc/auto.master.test #Autofs file /nfs file:/etc/auto.home -rw,hard,intr,tcp,async,rsize=32768,wsize=32768,timeo=600 KK and removes KK if I remove some of the above defined vars.... So, why is it complaining about the uninitilized constant if it''s defined? and why it complains if the funtions already does something if the var is not defined? Anyone could give me a hand on this? TIA, Arnau -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 05/02/2011 03:24 PM, Arnau Bria wrote: <snip>> /nfs file:/etc/auto.home -rw,hard,intr,tcp,async,rsize=32768,wsize=32768,timeo=600 > <% if has_variable?("CVMFS_mountpoint") and has_variable?("CVMFS_file") %> > <%= CVMFS_mountpoint %> <%= CVMFS_file %> > <% end %> > > This gives : > > err: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template computing_autofs/auto.master.erb: uninitialized constant Puppet::Parser::TemplateWrapper::CVMFS_mountpoint at /etc/puppet/manifests/services/workernode/modules/computing_autofs/manifests/init.pp:35"Constant"? This is a complete shot in the dark, but have you tried downcasing those to "cvmfs_mountpoint" and "cvmfs_file"? Looks to me like ruby thinks its dealing with constants, whereas it should be looking for variables. HTH, Felix -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Mon, 02 May 2011 15:31:01 +0200 Felix Frank wrote: [...]> "Constant"? > > This is a complete shot in the dark, but have you tried downcasing > those to "cvmfs_mountpoint" and "cvmfs_file"?that worked!> Looks to me like ruby thinks its dealing with constants, whereas it > should be looking for variables.so, any ideawhy is ruby doing it?> HTH, > FelixThanks a lot Felix, Cheers, Arnau -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 05/02/2011 03:41 PM, Arnau Bria wrote:> On Mon, 02 May 2011 15:31:01 +0200 > Felix Frank wrote: > > [...] >> "Constant"? >> >> This is a complete shot in the dark, but have you tried downcasing >> those to "cvmfs_mountpoint" and "cvmfs_file"? > that worked! > >> Looks to me like ruby thinks its dealing with constants, whereas it >> should be looking for variables. > > so, any ideawhy is ruby doing it?I know next to nothing about Ruby, but apparently the naming conventions are rather strict in the language ;-) Glad that fixed it, Felix -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Christian Kauhaus
2011-May-02 14:17 UTC
Re: [Puppet Users] help with template and has_variable?
Am 02.05.2011 15:41, schrieb Arnau Bria:> so, any ideawhy is ruby doing it?Identifiers beginning with uppercase letters denote constants in Ruby. The most visible example for this rule are class names. Class names are constants that point to their respective class objects. Regards Christian -- Dipl.-Inf. Christian Kauhaus <>< · kc@gocept.com · systems administration gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany http://gocept.com · tel +49 345 1229889 11 · fax +49 345 1229889 1 Zope and Plone consulting and development -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.