‘Can’t convert nil into String’ error upon Puppet run

puppetselinux

When attempting to use modules copied into the Puppet modules directory, my puppet client returns ' Could not retrieve catalog from remote server: Error 400 on SERVER: can't convert nil in String' errors when connecting to the Puppet master server.

[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

Code all checks out and is valid. SELinux is turned on.

Best Answer

In this case, the files were moved with 'mv' instead of copied with 'cp'. SELinux does not change the files to the default context of the destination with 'mv' as it would with 'cp'.

Because of this, Puppet could not read the module files and thus the 'include' was failing in the calling .pp file. Because the read was failing, there was a 'nil' where code was expected to be.

Verify the SELinux properties of the Puppet module directories.

Puppet has its own SELinux settings and your files there should be set to it. If copied in from elsewhere, they'll be incorrect.

[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

To set this back to the default, you can run restorecon -R /etc/puppet, which will recursively reset all the puppet modules to functional SELinux settings for use in Puppet.

HT: @MichaelHampton

Related Topic