Hello, all.

I am unable to get the utilize the output of a custom fact in a template
while, simultaniously, succeeding at doing so with another custom fact. I
receive no errors and am utterly at a loss. The failing custom fact that
looks like this:

# cat /var/lib/puppet/lib/facter/memorysize_mb.rb
# As seen in:
http://groups.google.com/group/puppet-users/browse_thread/thread/f1c0689dad937853/095d3109f1a8b284

require 'facter'
Facter.add("memorysize_mb") do
  confine :kernel => :Linux
  ram = 0
  # Steal linux's meminfo
  File.open( "/proc/meminfo" , 'r' ) do |f|
    f.grep( /^MemTotal:/ ) { |mem|
      ram = mem.split( / +/ )[1].to_i / 1024
    }
  end
  setcode do
    ram
  end
end


The following works great:

# facter --puppet memorysize_mb
17495


Just like I expect; just like as advertised here:
http://www.puppetlabs.com/blog/facter-part-2-testing-and-deployment/ and
here http://projects.puppetlabs.com/projects/1/wiki/Adding_Facts and here
http://www.krzywanski.net/archives/666 . Everything looks to be going
smooth. Indeed, I already have another custom fact that I'm using to great
success in templates already. Looks like this:

# cat /var/lib/puppet/lib/facter/stack_depth.rb

require 'facter'

Facter.add('stack_depth') do
  setcode do
    %x{bash -c 'ulimit -s'}.chomp.to_i
  end
end


In my template when I do

maintenance_work_mem = <%= memorysize_mb.to_i * 0.15 %>MB
max_stack_depth = <%= stack_depth.to_i - 1000 %>kB


the rendered configuration is

maintenance_work_mem = MB
max_stack_depth = 7192kB


Oh god, why?

-- 
Brian L. Troutwine

-- 
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