Multiple masters - node.rb and facts directory

I'm working on setting up multiple puppet masters to load balance and
initial tests once I got the second one operational I realized it had no
YAML files in /var/lib/puppet/yaml/facts which is queried by the node.rb
ENC script used with Foreman. Is there a supported / known way to make
multiple masters work with Foreman in relation to using the node.rb ENC
script? I could put the /var/lib/puppet/yaml directory on a NFS mount
shared by the Puppet masters but that seems unnecessary given Puppet
supports multiple masters and makes no mention of having to "sync" facts
using a shared filesystem. I'm also running PuppetDB so it seems likely
that could be utilized as the shared resource between all masters, but
unsure if that's the right approach for the ENC script.

Thanks,

  • Trey

I have multiple masters (load balanced using SRV records) which use
PuppetDB and have put TheForeman alongside them.

So with my setup records could be on any master for any client depending on
where DNS routes them too. I run the nodes.rb via cron with --push-facts on
each node (different frequency just in case) and if it finds something it
uploads it. If not no matter.

Whilst TheForeman is single node only and every other aspect is
load-balanced HA the next stage is to do this with Foreman.

··· On Saturday, 12 July 2014 06:31:45 UTC+1, treydock wrote: > > I'm working on setting up multiple puppet masters to load balance and > initial tests once I got the second one operational I realized it had no > YAML files in /var/lib/puppet/yaml/facts which is queried by the node.rb > ENC script used with Foreman. Is there a supported / known way to make > multiple masters work with Foreman in relation to using the node.rb ENC > script? I could put the /var/lib/puppet/yaml directory on a NFS mount > shared by the Puppet masters but that seems unnecessary given Puppet > supports multiple masters and makes no mention of having to "sync" facts > using a shared filesystem. I'm also running PuppetDB so it seems likely > that could be utilized as the shared resource between all masters, but > unsure if that's the right approach for the ENC script. > > >

It's only used to upload the facts to Foreman at the start of the ENC
script. This is useful because (by default) Foreman will then create a
new host with the data if it doesn't exist yet. This is the heart of
the ENC function, because otherwise Foreman will return 404 for the
actual YAML request, and the Puppetmaster will log an error.

That said, it's the puppetmaster that writes those files when the
agent connects, so the file should always be accessible for the ENC
script to upload. There shouldn't be a situation where it doesn't
exist due to load balancing, because the agent only makes one
connection, and then waits for a manifest to be returned. The master
then writes the facts that the agent sent, and calls node.rb, which
will upload them.

If that's not working as described, then I think we could do some
debugging to find out why.

Greg

··· On 12 July 2014 06:31, treydock wrote: > I'm working on setting up multiple puppet masters to load balance and > initial tests once I got the second one operational I realized it had no > YAML files in /var/lib/puppet/yaml/facts which is queried by the node.rb ENC > script used with Foreman.

The issue I saw I have always seen and at the time attributed it to
multiple masters, but it's simply what I always see when a node runs for
the first time.

The issue will be that if I have 300 nodes, and bring a new master online,
half of them will receive this error the first time they contact the new
master.

Warning: Unable to fetch my node definition, but the agent run will
continue:
Warning: Error 400 on SERVER: Failed to find dev01.brazos.tamu.edu via
exec: Execution of '/etc/puppet/node.rb dev01.brazos.tamu.edu' returned 1:

A subsequent puppet runs do not generate that error. This is something
I've seen for a long time with Foreman's ENC script with new nodes, but
will also occur the first time a node hits a puppet master in the
multi-master setup.

  • Trey
··· On Saturday, July 12, 2014 7:57:37 AM UTC-5, Greg Sutcliffe wrote: > > On 12 July 2014 06:31, treydock <trey...@gmail.com > wrote: > > I'm working on setting up multiple puppet masters to load balance and > > initial tests once I got the second one operational I realized it had no > > YAML files in /var/lib/puppet/yaml/facts which is queried by the node.rb > ENC > > script used with Foreman. > > It's only used to upload the facts to Foreman at the start of the ENC > script. This is useful because (by default) Foreman will then create a > new host with the data if it doesn't exist yet. This is the heart of > the ENC function, because otherwise Foreman will return 404 for the > actual YAML request, and the Puppetmaster will log an error. > > That said, it's the puppetmaster that writes those files when the > agent connects, so the file *should* always be accessible for the ENC > script to upload. There shouldn't be a situation where it doesn't > exist due to load balancing, because the agent only makes one > connection, and then waits for a manifest to be returned. The master > then writes the facts that the agent sent, and calls node.rb, which > will upload them. > > If that's not working as described, then I think we could do some > debugging to find out why. > > Greg >