On Monday, April 21, 2014 4:45:09 PM UTC-5, zjhe...@gmail.com wrote:
>
> Having an odd issue with the facts inside an ERB template.  I'm using the 
> facts to build a somewhat dynamic MOTD.  I made some changes to init.pp for 
> the module and deployed to my Dev environment and it started breaking 
> things.  It started off with not being able to find a value for 
> lsbdistdescription
>
> Could not retrieve catalog from remote server: Error 400 on SERVER: Failed 
> to parse template motd/motd.erb: Filepath: 
> /usr/lib/ruby/site_ruby/1.8/puppet/parser/templatewrapper.rb Line: 81 
> Detail: Could not find value for 'lsbdistdescription' at 
> /etc/puppet/environments/development/modules/motd/templates/motd.erb:10 at 
> /etc/puppet/environments/development/modules/motd/manifests/init.pp:44 on 
> node cbe01d.example.com
>
> Looking into the issue the only thing I found was that facts should now 
> have an @ sign in front of them.
>


That is the current recommendation, but it is not a requirement.  Bare 
variable names work, too.

 

> Changing that didn't help.  I have reverted back to the old code and its 
> still broken.  Oddly enough, it works as expected when I go to the server 
> and run $ sudo puppet agent -t.  It applies the lsbdistdescription to MOTD, 
> then the puppet daemon fires off after 30minutes and does not acknowledge 
> lsbdistdescription.
>


So, under what conditions does it *not* work?  Because running the agent on 
the node that hosts the master is not fundamentally different from running 
it on any other node.

 

>
> Here is the current template:
> +++++++++++++++++: System Data :+++++++++++++++++++
> + Hostname = <%= hostname %>
> + Domain = <%= domain %>
> + Address = <%= ipaddress_eth0 %>
> + OS: <%= @lsbdistdescription %> <%= architecture %> 
> + Kernel = <%= kernelrelease %>
> + Uptime = <%= uptime %>
> + CPU = <%= processorcount %>x  <%= processor0 %>
> + Total Memory = <%= memorysize %>
> + Managed by Puppet version <%= puppetversion %>
> <% if @extra -%>
> + Extra Info = <%= @extra %>
> <% end -%>
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Any ideas why only manual runs work as expected?
>
>

The problem is much more likely to be tied to specific target nodes than to 
be related to the manner in which you launch the agent.  In particular, 
whether the LSB-related facts are provided by a given node may depend on 
whether a particular package is installed there.  And that makes sense, 
too, because such machines might not comply with any version of the LSB.

A quick look at the Facter code confirms that only nodes that provide the 
lsb_release command will assert the lsbdistdescription fact.  On 
RedHat-family Linuxes that command is provided by the "redhat-lsb" package.

Going forward, you clearly cannot rely on your nodes to provide LSB-related 
facts.  You could probably work around this issue by putting this 
declaration in the class or definition that uses the template:

$lsbdistdescription = "${::lsbdistdescription}"

That reliably sets a local variable that itself is always present, and that 
will shadow the global fact if the fact exists.  The local variable will 
have the same value as the global, or an empty value if the global does not 
exist.  Of course, you could get more creative, too.  For example, you 
could arrange to provide a non-empty default value when there is no 
lsbdistdescription.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/35d0cb46-785a-401f-b1dd-17b7947572e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to