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

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

当尝试使用复制到 Puppet 模块目录中的模块时,我的 Puppet 客户端在连接到 Puppet 主服务器时返回“无法从远程服务器检索目录:服务器上的错误 400:无法将字符串中的 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

代码全部检查通过且有效。SELinux 已打开。

答案1

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

因此,Puppet 无法读取模块文件,因此调用 .pp 文件中的“include”失败。由于读取失败,代码预期所在的位置显示为“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

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

HT:@MichaelHampton

相关内容