Puppet Facts » History » Version 13

« Previous - Version 13/16 (diff) - Next » - Current version
Ohad Levy, 07/25/2012 02:47 PM

Puppet Facts

Hello, This page tries to summarize the many ways you can get your facts visible in Foreman.

If you are planning using Foreman as your Puppet External Nodes Classifier, the recommended approach would be using the ENC script, which both updates your facts, and fetch the information at the same time.

If You Are Using Puppet Storeconfigs

Note: starting from version 0.2, this is no longer required.
Foreman will automatically refresh the host facts once a puppet report comes in if you setup Foreman to use the same database as storeconfigs in the database.yml file.

Earlier versions should follow:

Puppet storeconfigs option will ensure that your puppetmaster processes will actually update the database, therefore,
you should just see the facts while browsing foreman.

In order to prepare your system for Unattended installations you should probably run:

rake puppet:migrate:populate_hosts RAILS_ENV=production

This will create all required settings from your facts.

Missing facts when using storeconfigs

If nodes are finishing their catalog runs, although the hosts operating system description is missing. Ensure that your /etc/puppet/puppet.conf contains the dbadapter under the [master] section. Add the following and either wait for a node to check in again, or manually run it with puppetd --test for this information to be updated.



  dbuser= puppetuser
  dbpassword= puppetpass
  dbserver= mysql.domain.com

Not using Puppet storeconfigs

Running Foreman on the same machine as the puppetmaster

If you run Foreman on the same machine as your puppetmaster and you have only one puppet master, you probably want to create a simple cronjob:

rake puppet:import:hosts_and_facts RAILS_ENV=production

this will import your facts (only new facts) every time you run the script.

But I have many puppet masters, or Foreman is on another server

Pushing facts through HTTP directly to Foreman

Foreman accepts remote puppetmaster sending their nodes facts through http, making it effective way to send facts over WAN.

the script is meant to run on each of your puppetmasters.
it will scan over all of the new fact files (from its last run) and will send them to foreman.

You will need to edit the script and set the Foreman URL (based on where Foreman is located in your setup).

You should run this script in a cronjob, if you have many puppet masters, you might consider adding a simple sleep argument (as mentioned inside the script header), this will avoid all of your puppetmasters hammering your database at the same time.

local file system access to fact yaml files

The previously mentioned rake task accepts a dir parameter, which means you can tell it to import facts from any directory.
if you store your fact yaml on some network share, or if you want to mount your puppetmaster you can:

rake puppet:import:hosts_and_facts dir=/my/dir/with/yaml/files RAILS_ENV=production

However, I would not recommend this option if you have any network latency or if it requires you to run an NFS (or sshfs) etc