Custom facts and environments

398 views
Skip to first unread message

JonY

unread,
Sep 23, 2014, 8:30:40 AM9/23/14
to puppet...@googlegroups.com
I'm attempting to make the jump to directory-based environments and am curious about what to do with custom facts.

In my current config I've tried putting custom facts into a separate module as /etc/puppet/modules/facts/{manifest,lib} and /etc/puppet/modules/facts/lib/facter/<modules go here>. I haven't had any success in getting these to propagate to clients though. 

I've added 'pluginsync=true' to puppet.conf on server/clients.

Reading the various docs doesn't make it sound like I need a manifest for custom facts. Truth? How about a class file?

Questions:

1. What step(s) did I miss in getting my facts to be distributed?
2. When I split up my network into 'production', 'test', etc folders for use in environments - what happens to custom facts then?
Message has been deleted

David LeVene

unread,
Sep 24, 2014, 4:36:07 AM9/24/14
to puppet...@googlegroups.com
In reply to myself... (as i'm really not an expert) our setup is actually using module/lib/facter as noted here https://docs.puppetlabs.com/guides/plugins_in_modules.html

and below is an example of my test env, which works with facts.

/etc/puppet/environments/production/modules/base/lib/facter/puppet_info.rb
/etc/puppet/environments/staging/modules/base/lib/facter/puppet_info.rb
/etc/puppet/environments/test/modules/base/lib/facter/puppet_info.rb

As you can see i'm very much learning as I go as well.

On Wednesday, 24 September 2014 17:58:08 UTC+9:30, David LeVene wrote:
Hey JonY,

Firstly, i'm not an expert but hopefully this assist you

We are using the single dir config as we're currently running on an older version of puppet, but this link should give you the information you require. 

A snippet from the page above says..
The best way to distribute external facts is with pluginsync, which added support for them in Puppet 3.4/Facter 2.0.1. To add external facts to your puppet modules, just place them in<MODULEPATH>/<MODULE>/facts.d/

eg /etc/puppet/environments/production/modules/<modulename>/facts.d/<fact_name>.rb

Each environment will use its own custom facts which is what you want so you can test a custom fact in the test env (/etc/puppet/environments/test/modules/base/lib/facter/) before you push to others etc.

Having the custom fact present in this directory should deploy it on the servers (it does for me!)

To answer your 2 questions directly;
1. What step(s) did I miss in getting my facts to be distributed?
   None from what I've seen - just your custom facts are in the wrong folder
2. When I split up my network into 'production', 'test', etc folders for use in environments - what happens to custom facts then?
   The facts are unique per environment

Hope this helps

Cheers
David

JonY

unread,
Sep 24, 2014, 8:14:16 AM9/24/14
to puppet...@googlegroups.com
Follow-up:

1. I used the directions from this post (https://groups.google.com/forum/#!topic/puppet-users/irSCu9SVoh4

       and the new 'fact' began to appear in /var/lib/puppet/lib/facter -- why?  an empty 'site.pp' file? is there some way to regulate which hosts get this?
       NOTE - I didn't add the 'factdir' line to 'puppet.conf' on the server. 

2. If I run 'facter' on a client I don't see my custom fact in the list.. but.. it's appearing on the server via puppetdb - why?

This seems to need some more documentation. It's a bit too random / mysterious.

jcbollinger

unread,
Sep 24, 2014, 9:34:13 AM9/24/14
to puppet...@googlegroups.com


On Tuesday, September 23, 2014 7:30:40 AM UTC-5, JonY wrote:
I'm attempting to make the jump to directory-based environments and am curious about what to do with custom facts.

In my current config I've tried putting custom facts into a separate module as /etc/puppet/modules/facts/{manifest,lib} and /etc/puppet/modules/facts/lib/facter/<modules go here>. I haven't had any success in getting these to propagate to clients though. 

I've added 'pluginsync=true' to puppet.conf on server/clients.

Reading the various docs doesn't make it sound like I need a manifest for custom facts. Truth? How about a class file?


Correct, you do not need a manifest for custom facts.  Manifests are instructions for constructing parts of nodes' catalogs.  They can use the values of custom facts, but they are not involved in installing custom fact implementations on clients.  That's what pluginsync is for.

I don't know what you mean by a "class file", as distinguished from a manifest.
 

Questions:

1. What step(s) did I miss in getting my facts to be distributed?
2. When I split up my network into 'production', 'test', etc folders for use in environments - what happens to custom facts then?


Custom facts should be in modules.  Typically they are in the same module as the classes that use them, but in principle, it should not be a problem for them to appear in their own, separate module.  For a given node, the pluginsync process will sync plugins, including custom facts, from the modules in the modulepath of the environment to which that node belongs.  Therefore, if your facts are not getting distributed then a modulepath issue is one of the things to consider.

Also, running plain 'facter' on a client will compute and present only the standard facts.  If you want also custom facts from Puppet then use 'facter -p'.


John

JonY

unread,
Sep 24, 2014, 9:44:19 AM9/24/14
to puppet...@googlegroups.com
"For a given node, the pluginsync process will sync plugins, including custom facts, from the modules in the modulepath of the environment to which that node belongs."

So if my modulepath is /etc/puppet/modules - pluginsync will grab everything from 'lib' folders under that (IE /etc/puppet/modules/.../lib ) regardless of whether it is referenced for a given client? Seems a tad confusing as other elements from this path (other modules) aren't sent to a given client without appearing in the node classifier for that client.

Garrett Honeycutt

unread,
Sep 24, 2014, 10:45:00 AM9/24/14
to puppet...@googlegroups.com
Hi,

Knowing or remembering that you have to type `facter -p` is confusing.
I've created a ticket to have this the default behavior that you can
vote on.

https://tickets.puppetlabs.com/browse/FACT-713

Best regards,
-g

--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

jcbollinger

unread,
Sep 25, 2014, 10:06:05 AM9/25/14
to puppet...@googlegroups.com


On Wednesday, September 24, 2014 8:44:19 AM UTC-5, JonY wrote:
"For a given node, the pluginsync process will sync plugins, including custom facts, from the modules in the modulepath of the environment to which that node belongs."

So if my modulepath is /etc/puppet/modules - pluginsync will grab everything from 'lib' folders under that (IE /etc/puppet/modules/.../lib ) regardless of whether it is referenced for a given client? Seems a tad confusing as other elements from this path (other modules) aren't sent to a given client without appearing in the node classifier for that client.


Pluginsync will sync all the <modulepath>/<any_module>/lib/facter/* (custom fact implementations).  These all WILL be used by the client, though the resulting facts might or might not be afterward referenced by the server.  It will also sync custom types and providers from <modulepath>/<any_module>/lib/puppet/type/* and <modulepath>/<any_module>/lib/puppet/provider/*.  Whether or not the types and providers are used by the client depends on the contents of its catalog, but that isn't known yet (even by the master) when plugins are synced, as it may depend on the custom facts.  Manifests are not synced, but they are not useful to clients (in master / agent mode), and anyway they are not plugins.  All of this applies to EVERY module in the applicable module path.

If you have not already done so, you should consult the documentation for distributing plugins.


John

Reply all
Reply to author
Forward
0 new messages