Project

General

Profile

Puppet Facts » History » Version 12

Version 11 (Ohad Levy, 10/11/2011 03:43 AM) → Version 12/16 (Ohad Levy, 02/21/2012 08:07 AM)

{{toc}}

h1. 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.

h2. 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:
<pre>
rake puppet:migrate:populate_hosts RAILS_ENV=production
</pre>

This will create all required settings from your facts.

h3. 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.

_/etc/puppet/puppet.conf_
<pre>
[master]

storeconfigs=true
dbadapter=mysql
dbuser= puppetuser
dbpassword= puppetpass
dbserver= mysql.domain.com
</pre>

h2. Not using Puppet storeconfigs

h3. 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:
<pre>
rake puppet:import:hosts_and_facts RAILS_ENV=production
</pre>

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

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

h4. 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":https://github.com/theforeman/puppet-foreman/blob/283619064fbde0275235535b19c53da249357035/files/push_facts.rb "script":https://github.com/ohadlevy/puppet-foreman/blob/master/foreman/files/push_facts.rb 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.

h4. 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:
<pre>
rake puppet:import:hosts_and_facts dir=/my/dir/with/yaml/files RAILS_ENV=production
</pre>

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