2

According to this puppet labs article, I can create custom facts from shell scripts.

I have created a bash script that returns a single fact, it is packaged in a modules facts.d directory. The module is included on the target system via an ENC class. When invoked by the puppet agent on the target it returns an empty set, when run by hand on the agent it correctly returns the fact. The script has execute permission on the master, but does not have it on the agent.

I saw a bug report related to permissions and file types, but that was windows and supposed to be fixed in puppet version 3.

What am I doing wrong?

ENC definition:

--- classes: facttest:

Shell script:

#!/bin/bash echo "test_fact1=$(hostname)"

Permissions:

master: -rwxr-xr-x 1 root root ... modules/facttest/facts.d/testfact.sh agent: -rw-r--r-- 1 root root ... /var/lib/puppet/facts.d/testfact.sh

Agent message:

Fact file /var/lib/puppet/facts.d/testfact.sh was parsed but returned an empty data set

Version information: Puppet master: 3.5.1 (Debian) Facter master: 2.0.1 Puppet agent: 3.6.1 (OpenSUSE) Facter agent: 2.0.1

user3684494
  • 23
  • 1
  • 3
  • How do you go about "running by hand" on the agent? – Felix Frank Jun 04 '14 at 12:28
  • Have you tried with the full path to the hostname command? – wzzrd Jun 04 '14 at 18:40
  • Running by hand: literally `sh /var/lib/puppet/facts.d/testfact.sh`. I also tried the full path to commands in the script, it made no difference. This was a simplified test case, the real script did more. – user3684494 Jun 04 '14 at 22:45
  • Ah, well - `sh ` will work independently of the permissions of course. That is probably why you couldn't reproduce your issue locally. – Felix Frank Jun 05 '14 at 11:50

1 Answers1

3

This is actually a bug in Puppet 3.6, apparently.

As an aside, note that using agents that are newer than the master is not generally supported.

Felix Frank
  • 3,093
  • 1
  • 16
  • 22
  • Advice taken - master now at same level as agents :) – user3684494 Jun 05 '14 at 23:50
  • Sorry to reopen an old post. but I stumbled across the same problem. Both server and client running on CentOS 7.1 and both the puppet version is 3.8.7. When I execute the script, it returns the fact as expected on both host...but not while doing it by a module. What am I missing? – unixbhaskar Nov 27 '17 at 11:06