Ask Your Question
3

How to access custom facts from command line?

asked 2017-01-04 22:31:28 -0500

jack9 gravatar image

updated 2017-01-05 23:07:56 -0500

i installed the puppetlabs-lvm module which provides some custom facts like lvm_pv_0

having the warning($facts['lvm_pv_0']) in my site.pp correctly outputs /dev/md0 but runningfacter | grep lvm or puppet facts | grep lvm from command line does not return anything. i have not checked them all but it looks like that every custom fact is missing from the command line.

how to access the custom facts from the command line?

update:

  • just for info:
  • puppet version: 4.8.1
  • os: debian 8 jessie
  • tested on: vagrant+virtualbox & bare metal

i run the commands as root, i already tried facter -p / facter --puppet. maybe my wording is wrong, not sure if custom facts are the same as "custom" facts from modules

in my example of the puppetlabs-lvm module, the facts are located in `modules/lvm/lib/facter/lvm_support.rb the facts are loaded and correctly accessible on a puppetrun in vagrant or when connected on a puppetmaster. only on the commandline the facts are missing.

the ommand puppet config print factpath has the following output for me /opt/puppetlabs/puppet/cache/lib/facter:/opt/puppetlabs/puppet/cache/facts both directories are empty. the directories given in a answer below/var/lib/puppet/lib/facter:/var/lib/puppet/facts does not exist.

extra question: where should custom facts be stored on a node?

edit retag flag offensive close merge delete

Comments

1

have you tried facter -p in your puppet client?

c4f4t0r gravatar imagec4f4t0r ( 2017-01-05 03:10:02 -0500 )edit

yes i tried facter -p, same result

jack9 gravatar imagejack9 ( 2017-01-05 22:13:52 -0500 )edit

4 Answers

Sort by ยป oldest newest most voted
1

answered 2017-01-05 23:49:21 -0500

jack9 gravatar image

solution for my problem was to add the environment to the call

puppet facts --environment puppet | grep lvm

edit flag offensive delete link more
1

answered 2017-01-05 09:25:38 -0500

DarylW gravatar image

updated 2017-01-05 09:27:37 -0500

I have also sometimes seen permissions or path issues on the custom facts.. I need to run 'sudo facter -p' OR (in a puppet 3.7.4 env) I need to use FACTERLIB=/var/lib/puppet/lib/facter:/var/lib/puppet/facts facter -p to see any custom facts from modules.

Let me know if either of those types of configurations help you.

The root/non-root difference could be seen in the factpath that is being used. If you run puppet config print factpath and sudo puppet config print factpath they probably point to different locations. You could use the 'root' puppet factpath as your FACTERLIB path when running facter as your regular user

edit flag offensive delete link more

Comments

sadly it has not helped. i updated my question with extra info. the directories you named are nonexisting in my system

jack9 gravatar imagejack9 ( 2017-01-05 23:09:19 -0500 )edit
0

answered 2017-01-17 07:53:54 -0500

Davies gravatar image

updated 2017-01-17 07:55:28 -0500

The command I have been using is puppet facts find $certname --render-as yaml | grep $factname. Obviously you will need to change this for your machine's certificate. If you want to use the trailing pipe to grep, you will need to give an existing $factname, too.

edit flag offensive delete link more
0

answered 2017-01-05 19:27:43 -0500

natemccurdy gravatar image

Add -p to your facter run to show custom facts installed via Puppet modules.

Like this:

facter -p lvm_pv_0

edit flag offensive delete link more

Comments

tried that before. unfortunately it has not worked

jack9 gravatar imagejack9 ( 2017-01-05 22:15:03 -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: 2017-01-04 22:31:28 -0500

Seen: 247 times

Last updated: Jan 17