facter 3.2 global custom facts directory?

387 views
Skip to first unread message

dkoleary

unread,
May 27, 2016, 7:28:50 PM5/27/16
to Puppet Users
Hey;

I'm drafing some custom facts that I would like to have available to everyone even outside of puppet.  The facts themselves work just fine for root and will work for normal users if I specify the --external-dir option:

$ sudo facter env                                     
tst
$ facter --external-dir=/opt/puppetlabs/facter/facts.d env
tst

Without that, facter run as a normal user doesn't find the script. Is there a config file somewhere that I can specify, globally, that custom facts are in /opt/puppetlabs/facter/facts.d or a default global directory (facter --debug doesn't seem to show one...)? Alternatively, I could set an alias in /etc/profile so everyone gets it but that seems like a bit of a kludge.

Any info is appreciated.

Thanks

Doug O'Leary

Christopher Wood

unread,
May 27, 2016, 8:38:48 PM5/27/16
to puppet...@googlegroups.com
All the custom facts here in /etc/facter/facts.d have worked just fine across the facter 2.4.4 -> facter 3.1.6 upgrade.

https://docs.puppet.com/facter/3.1/custom_facts.html
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/a9867381-4b0d-457e-aea3-173730ac86cf%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/a9867381-4b0d-457e-aea3-173730ac86cf%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

dkoleary

unread,
May 27, 2016, 10:15:12 PM5/27/16
to Puppet Users
Thanks for the response. I'm pretty sure I tried /etc/faster/facts.d; but, I'll confirm that.

Thanks again.

Christopher Wood

unread,
May 28, 2016, 12:18:13 PM5/28/16
to puppet...@googlegroups.com
Just to confirm that's a typo below? You have an "s" in facter.

/etc/facter/facts.d

On Fri, May 27, 2016 at 03:15:11PM -0700, dkoleary wrote:
> Thanks for the response. I'm pretty sure I tried /etc/faster/facts.d; but, I'll confirm that.
>
> Thanks again.
>
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/2dacc5a3-1b67-4ec3-b2f0-0b338ceaa2b4%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

dkoleary

unread,
May 28, 2016, 1:22:46 PM5/28/16
to Puppet Users, christop...@pobox.com
Hey;

Thanks; yes, that was a typo.  Responding from an ipad on a shaky surface... bit surprised that was the only one.

Any rate, I now have fact scripts in /etc/facter/facts.d

$ ltree /etc/facter/facts.d
drwxr-xr-x. 2 root root 4096 May 28 08:07 /etc/facter/facts.d
drwxr-xr-x. 3 root root 4096 May 28 08:06 /etc/facter
drwxr-xr-x. 122 root root 12288 May 28 08:06 /etc

A cleaned up root debug facter run shows that root is hitting all three directories:

sudo facter --debug env 2>&1
2016-05-28 08:11:41.053089 INFO  puppetlabs.facter - executed with command line: --debug env.
[[snip]]
2016-05-28 08:11:41.079647 INFO  puppetlabs.facter - requested queries: env.
2016-05-28 08:11:41.079776 DEBUG puppetlabs.facter - fact "facterversion" has resolved to "3.2.0".
2016-05-28 08:11:41.080092 DEBUG puppetlabs.facter - searching "/opt/puppetlabs/facter/facts.d" for external facts.
[[snip]]
2016-05-28 08:11:41.091406 DEBUG | - env=tst
2016-05-28 08:11:41.091561 DEBUG puppetlabs.facter - fact "env" has resolved to "tst".
2016-05-28 08:11:41.091700 DEBUG leatherman.execution:555 - process exited with status code 0.
2016-05-28 08:11:41.091785 DEBUG puppetlabs.facter - completed resolving facts from executable file "/opt/puppetlabs/facter/facts.d/hosts".
2016-05-28 08:11:41.091933 DEBUG puppetlabs.facter - searching "/etc/facter/facts.d" for external facts.
[[snip]]
2016-05-28 08:11:41.103835 DEBUG | - env=tst
2016-05-28 08:11:41.103998 DEBUG puppetlabs.facter - fact "env" has changed from "tst" to "tst".
2016-05-28 08:11:41.104163 DEBUG leatherman.execution:555 - process exited with status code 0.
2016-05-28 08:11:41.104294 DEBUG puppetlabs.facter - completed resolving facts from executable file "/etc/facter/facts.d/hosts".
2016-05-28 08:11:41.104428 DEBUG puppetlabs.facter - searching "/etc/puppetlabs/facter/facts.d" for external facts.
[[snip]]
2016-05-28 08:11:41.116165 DEBUG | - env=tst
2016-05-28 08:11:41.116332 DEBUG puppetlabs.facter - fact "env" has changed from "tst" to "tst".
2016-05-28 08:11:41.116493 DEBUG leatherman.execution:555 - process exited with status code 0.

Does emphasize the point that I should have those in one and only one of those directories...

Following is the same debug run (with nothing snipped) from a non-root user showing that it's not hitting any of those directories:

$ facter --debug env
2016-05-28 08:16:03.979516 INFO  puppetlabs.facter - executed with command line: --debug env.
2016-05-28 08:16:03.980478 INFO  leatherman.ruby:133 - ruby loaded from "/opt/puppetlabs/puppet/lib/libruby.so.2.1.0".
2016-05-28 08:16:04.006387 INFO  leatherman.ruby:182 - using ruby version 2.1.9
2016-05-28 08:16:04.006507 INFO  puppetlabs.facter - requested queries: env.
2016-05-28 08:16:04.006616 DEBUG puppetlabs.facter - fact "facterversion" has resolved to "3.2.0".
2016-05-28 08:16:04.006961 DEBUG puppetlabs.facter - skipping external facts for "/home/doug.oleary/.puppetlabs/opt/facter/facts.d": No such file or directory
2016-05-28 08:16:04.007032 DEBUG puppetlabs.facter - skipping external facts for "/home/doug.oleary/.facter/facts.d": No such file or directory
2016-05-28 08:16:04.007065 DEBUG puppetlabs.facter - no external facts were found.
2016-05-28 08:16:04.007681 DEBUG puppetlabs.facter - loading all custom facts.
2016-05-28 08:16:04.007756 DEBUG puppetlabs.facter - fact "env" does not exist.

It looks like facter, run as a non-root user, is limited to personal home directories.  So, rephrasing the original question: is there some way to tell non-root facter runs to use the standard directories without having to add '--external-dir' everytime?

Thanks for the responses.

Doug O'Leary

Christopher Wood

unread,
May 28, 2016, 4:05:56 PM5/28/16
to puppet...@googlegroups.com
I thought it might too, but turns out probably not:

https://projects.puppetlabs.com/issues/11449
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/4f531be5-d659-46ba-9c57-4d5391f3f114%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/4f531be5-d659-46ba-9c57-4d5391f3f114%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

Reply all
Reply to author
Forward
0 new messages