1

我是 ruby​​ 的新手,正在尝试让 puppet 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

代码的想法是创建一个名为 的自定义事实mounts,然后可以在模块的清单中使用它。这是清单文件中的一节:

if ("/tmp" in $mounts) {
  mount{'tmpfs_mnt':
    name     => "/tmp",
    options  => [ 'nodev','nosuid','noexec' ],
    ensure   => present,
    atboot   => true,
    fstype   => tmpfs,
    remounts => true,
  }
}

自定义事实似乎没有被创建。这是尝试拉取此模块时其中一个 puppet 节点的输出:

错误:无法从远程服务器检索目录:服务器上的错误 400:来自“in”表达式的右操作数的“undef”不是受支持的类型(字符串、数组或哈希)

对于需要进行哪些更正以使自定义事实正常工作的任何帮助,我们将不胜感激。

4

0 回答 0