I am new to ruby and am trying to get a puppet custom fact to work. Here is the code for the custom fact:
Facter.add("mounts") do
confine :osfamily => "RedHat"
setcode do
mountlist=""
#Facter::Core::Execution.exec('/bin/mount | /bin/cut -f3 -d" "')
#mounts=`/bin/mount`
mounts = Facter::Core::Execution.exec('/bin/mount')
mounts.each_line do |line|
fs=line.match(/^[^\s]+\s+on\s(.+) type.+/).captures
mountlist=mountlist + fs.to_s + ","
end
mountlist
end
end
The idea of the code is to create a custom fact called mounts
, which can then be used in a manifest for a module. Here is one of the stanzas from the manifest file:
if ("/tmp" in $mounts) {
mount{'tmpfs_mnt':
name => "/tmp",
options => [ 'nodev','nosuid','noexec' ],
ensure => present,
atboot => true,
fstype => tmpfs,
remounts => true,
}
}
The custom fact does not appear to get created. Here is the output from one of the puppet nodes when trying to pull this module:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 'undef' from right operand of 'in' expression is not of a supported type (string, array or hash)
Any help on what corrections are needed to get the custom fact working would be greatly appreciated.