Ask Your Question

Why is $facts is not a hash or array when accessing it

asked 2014-12-04 09:40:13 -0500

pvbouwel gravatar image

updated 2014-12-05 09:06:39 -0500

I get the following error:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: $facts["nrpe_plugins"] is not a hash or array when accessing it with CheckSystemErrors at /etc/puppet/environments/development/modules/site_custom/manifests/nagios_nrpe_plugin.pp:27 on node

The line of code that throws this is

if( !$facts['nrpe_plugins'] or ! $facts['nrpe_plugins']["$plugin_name"]) ...

So I access the $facts hash as described on puppetlabs doc

I have a puppet master that is newer than 3.5

[root@puppet]# puppet master --version

and I have configured the master to use (and trust) the client facts:

[root@iipc-unet02 puppet]# puppet config print --section master | grep "string\|trust"
ldapstring = (&(objectclass=puppetClient)(cn=%s))
trusted_node_data = true
stringify_facts = false

I am using puppet community edition

I thought I finally found the culprit. I had the config parameter immutablenodedata set to true.

It was in the doc . Now I changed it to false but now it looks like no fact is set at all. (My facts are on the agent node in /etc/facter/facts.d/nagiosnrpeplugins.yaml and I can see them using facter).

However in a puppet run it looks like they are not sent to the master.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-12-09 16:46:16 -0500

rnelson0 gravatar image

The $facts variable is a hash, it's the contents of $facts["nrpeplugins"] that are expected to be a hash or array and are not. How are you defining the fact nrpeplugins?

edit flag offensive delete link more


I added a file /etc/facter/facts.d/nagios_nrpe_plugins.yaml which is built using concat. First I addd main fact name: "nrpe_plugins:\n". Then for each plugin I use concat to add " $plugin_name:\n version: $vers" which results in something like: nrnpe_plugins: plug1: version: '1.0.3'

pvbouwel gravatar imagepvbouwel ( 2014-12-13 09:50:28 -0500 )edit

Newlines are ignored but it was shown as a hash by facter, I now have made a different setup by using system packages but still I wonder why this didn't work. For me it looked like the fact was not shipped to the master but now I am doubting. I'll try to reproduce but need to setup new test envir.

pvbouwel gravatar imagepvbouwel ( 2014-12-13 09:53:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-12-04 09:40:13 -0500

Seen: 2,731 times

Last updated: Dec 09 '14