Puppet sometimes can't find standard facts like osfamily
I've seen this issue on RedHat/CentOS. The puppet agent on the client machine would run out of file descriptors due to some ruby/puppet bug not closing them. After hitting the 1024 fd limit, it would not be able to run facter anymore, so the facts would be missing.
If subsequent puppet runs from the same process don't fail, it probably is a different problem, but it might be worth checking out. In my case puppet agent would log about not being able to start facter, and in /proc/PIDOFPUPPETD/fd
there'd be 1024 file descriptors.
I found source of my problem. It was my nagios plugin, that checks if puppet agent works and listen for connections (I run puppet agent with listen=true)
It looks like if there is more than 1 connection to puppet agent in one time, puppet can't gather facts. For example if my osfamily is "Debian", it returned just generic "Linux".
How I tested? I run 2 loops, with commands that connect to:
https://127.0.0.1:8139/production/facts/no_key
Example result:
OK: connection with puppet agent works (facter: 1.6.17, kernel: 2.6.32-5-amd64, os: Debian)
OK: connection with puppet agent works (facter: 1.6.17, kernel: 2.6.32-5-amd64, os: Debian)
OK: connection with puppet agent works (facter: 1.6.17, kernel: 2.6.32-5-amd64, os: Linux)
OK: connection with puppet agent works (facter: 1.6.17, kernel: 2.6.32-5-amd64, os: Debian)
OK: connection with puppet agent works (facter: 1.6.17, kernel: 2.6.32-5-amd64, os: Debian)
If I run loop with only 1 command, it works every time.
I'm not sure if it's really puppet problem, or something deeper (ruby modules), but to fix this issue, I need to stop connecting to puppet agent server.