external facts script not working, but only when puppet agent is run as a daemon

53 views
Skip to first unread message

Ugo Bellavance

unread,
Jun 30, 2017, 1:42:23 PM6/30/17
to Puppet Users
Hi,

I'm a beginner with PHP but I managed to get two scripts to work for generating external facts for a puppet module.  These scripts work perfectly when I run puppet manually (puppet agent --test), but when the puppet agent is started as a daemon (systmctl start puppet), facts are not generated. Both scripts give the same error:
start-puppet-agent: Fact file /var/lib/puppet/facts.d/get_extensions_details.php was parsed but returned an empty data set

start-puppet-agent: Fact file /var/lib/puppet/facts.d/get_directives_details.php was parsed but returned an empty data set

I wonder what kind of difference could cause that.

I tried debugging as much as I can, but it looks like the array $arr is not fed by the json_decode function. I think json support is built-in so the php config should not matter. PHP throws this error: invalid argument supplied for foreach()

Scripts:
https://github.com/zend-patterns/ZendServerPuppet/blob/master/facts.d/get_directives_details.php
https://github.com/zend-patterns/ZendServerPuppet/blob/master/facts.d/get_extensions_details.php

(still) running puppet 3

Thanks,

Ugo Bellavance

unread,
Jul 3, 2017, 3:20:12 PM7/3/17
to Puppet Users
I found it: the PHP script threw PHP Notices when run as a daemon because of uninitialized variables.  Got rid of them and now the script works when puppet agent is run as a daemon.

Ugo Bellavance

unread,
Jul 4, 2017, 8:37:09 AM7/4/17
to Puppet Users
What I meant exactly is that the error messages were added to the json, so when I tried to load the json into an array, I got an error saying that the input was not a standard json string.
Reply all
Reply to author
Forward
0 new messages