Puppet 运行时出现“无法将 nil 转换为字符串”错误

Mag*_*lan 2 selinux puppet

当尝试使用复制到 Puppet 模块目录中的模块时,我的 Puppet 客户端返回“无法从远程服务器检索目录:服务器上的错误 400:连接到 Puppet 主服务器时无法在字符串中转换 nil”错误。

[root@puppetmaster modules]# rpm -qa *puppet*
puppet-2.7.18-1.el6.noarch
puppet-server-2.7.18-1.el6.noarch

[root@puppetmaster modules]# uname -sr
Linux 2.6.32-279.el6.x86_64
Run Code Online (Sandbox Code Playgroud)

代码全部签出且有效。SELinux 已开启。

Mag*_*lan 7

在这种情况下,文件是用 'mv' 移动的,而不是用 'cp' 复制的。SELinux 不会像使用 'cp' 那样使用 'mv' 将文件更改为目标的默认上下文。

因此,Puppet 无法读取模块文件,因此“include”在调用 .pp 文件中失败。由于读取失败,因此预期代码为“nil”。

验证 Puppet 模块目录的 SELinux 属性。

Puppet 有自己的 SELinux 设置,您的文件应该设置为它。如果从其他地方复制过来,它们将是不正确的。

[root@puppetmaster modules]# ls -Z
drwxr-xr-x. root root unconfined_u:object_r:puppet_etc_t:s0 acroread
drwxr-xr-x. root root unconfined_u:object_r:puppet_etc_t:s0 apt
drwxr-xr-x.  999 1000 unconfined_u:object_r:admin_home_t:s0 bindserver
Run Code Online (Sandbox Code Playgroud)

要将其设置回默认值,您可以运行restorecon -R /etc/puppet,它将递归地将所有 puppet 模块重置为可在 Puppet 中使用的功能性 SELinux 设置。

HT:@迈克尔汉普顿