Ask Your Question
0

external facts reference

asked 2016-09-22 10:04:12 -0500

puser gravatar image

Hello,

Excuse my naivety but I am having a large amount of trouble with external facts. I have seen that you need to create a folder called

<manifest_name>/facts.d

to store external facts in. Inside my facts.d folder I have

<manifest_name>/facts.d/install_location.sh

Now inside my install_location.sh I have the following:

#!/bin/bash
OUTPUT="$(/bin/rpm -qa --queryformat \'%{FILENAMES}\' pkg_jvmtop)"
echo "JVMTOP_HOME=${OUTPUT}"

I know you need to return things in a key/value pair like

key=value

Thus I am echoing

echo "JVMTOP_HOME=${OUTPUT}"

I am getting several errors when attempting

puppet apply /fact.d/install_location.sh

Can someone explain (in great detail) what I am doing wrong and how to reference JVMTOP_HOME in my manifests? I assume it is stupid, below are the errors I am getting:

Error: This Name has no effect. A value was produced and then forgotten (one or more preceding expressions may have the wrong form) at        /etc/puppetlabs/code/environments/production/modules/jvmtop/facts.d/install_loc.sh:3:1
Error: Illegal attempt to assign to 'a Type-Name'. Not an assignable reference at /etc/puppetlabs/code/environments/production/modules/jvmtop/facts.d/install_loc.sh:2:1
Error: Found 2 errors. Giving up
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-09-22 13:43:28 -0500

lupin gravatar image

You can't execute an executable facts like what you did(puppet apply). Make sure your install_location.sh is executable and that indeed result a key=value pair. Then on a puppet node(with module that contains the fact) and pkg_jvmtop package is installed, you can query it with facter -p key - where key is the the key on your key=value pair.

edit flag offensive delete link more

Comments

I gotcha, I can now reference the key in my manifests however when I try the facter -p key it doesn't come up. Any idea what?

puser gravatar imagepuser ( 2016-09-22 14:05:42 -0500 )edit

I've had issues where I need to do 'sudo facter -p' to see my custom facts. The other alternative is to manually place the FACTER_LIB=/path/to/facts facter -p key (I can't remember the exact path right now). I also use that to reference my facts in irb for doing some debugging...

DarylW gravatar imageDarylW ( 2016-09-22 23:33:11 -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

Stats

Asked: 2016-09-22 10:04:12 -0500

Seen: 107 times

Last updated: Sep 22 '16