Ich was working with puppet
and facter
to collect information from the puppet node. Testing the *.rb
script however regularly failed with
WARN backup_key.rb - Command /opt/puppetlabs/facter/facts.d/backup_key.rb completed with the following stderr message: /opt/puppetlabs/facter/facts.d/backup_key.rb: 1: Syntax error: word unexpected (expecting ")")
The content of backup_key.rb
was correct:
Facter.add('backup_key') do setcode do Facter::Core::Execution.execute('/usr/bin/gpg --list-secret-keys | grep " [0-9A-Z]*$" | sed "s/\\\\s //g" | head -n1') end end
And if copying the file's content to a new file, it worked, whentesting with
facter --custom-dir /opt/puppetlabs/facter/facts.d | grep backup
Could it be the newline character? No, it was not.
--list-secret-keys
, this fact is intended for inventory purposes — to check whether the correct keys are deployed on the correct nodes. The name of the fact,backup_key
, initially made me worry that it was being used to back up PGP secret keys via Facter, which would be highly insecure, since facts are accessible to authenticated Puppet users via PuppetDB (queriable by Puppet manifests, API users, and RBAC-controlled interfaces) and can also be read locally by any user with sufficient permissions to runfacter
.