RILINDO FOSTER
2012-May-17 18:46 UTC
[Puppet Users] Custom Fact not in facts.yml during Puppet Runs
I wrote a custom fact called "xen_total_memory" that pulls the xen
memory from xm info:
require ''facter/util/memory''
begin
xen_total_memory = `xm
info`.grep(/total_memory/).to_s.split(/:/)[1].lstrip.chomp
rescue
xen_total_memory = ""
end
Facter.add(''xen_total_memory'') do
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
setcode do
xen_total_memory
end
end
Then I wrote another custom fact, similar to this one, except this time it looks
for free memory:
require ''facter/util/memory''
begin
xen_free_memory = `xm
info`.grep(/free_memory/).to_s.split(/:/)[1].lstrip.chomp
rescue
xen_free_memory = ""
end
Facter.add(''xen_free_memory'') do
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
setcode do
xen_free_memory
end
end
For some reason, I couldn''t see in mco with "moo facts
xen_free_memory". I took another look and found that I messed up on the
file extension, so I corrected it. So at this point, they are mostly the same:
LAPDTOP:facter rilindo$ diff xen_free_memory.rb xen_total_memory.rb
4c4
< xen_free_memory = `xm
info`.grep(/free_memory/).to_s.split(/:/)[1].lstrip.chomp
---> xen_total_memory = `xm
info`.grep(/total_memory/).to_s.split(/:/)[1].lstrip.chomp
6c6
< xen_free_memory = ""
---> xen_total_memory = ""
9c9
< Facter.add(''xen_free_memory'') do
---> Facter.add(''xen_total_memory'') do
12c12
< xen_free_memory
---> xen_total_memory
Yet, the problem persists.
Curious thing is that I can confirm that I can see the fact being loaded by
puppet and if you run it manually, it does populate the facts.yaml file. The
agent is just not inserting it during its runs.
The other custom facts are being loaded, so I am stumped.
- Rilindo
--
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.