Puppet Facts

Version 9 (Bryan Taylor, 06/23/2011 05:00 am)

1 1
{{toc}}
2 1
3 1
h1. Puppet Facts
4 1
5 1
h2. Using Puppet Storeconfigs
6 6 Ohad Levy
7 7 Ohad Levy
*Note:* starting from version 0.2, this is no longer required.
8 8 Cody Robertson
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.
9 6 Ohad Levy
10 6 Ohad Levy
Earlier versions should follow:
11 1
12 1
Puppet storeconfigs option will ensure that your puppetmaster processes will actually update the database, therefore,
13 1
you should just see the facts while browsing foreman.
14 1
15 1
In order to prepare your system for [[Unattended installations]] you should probably run:
16 1
<pre>
17 1
rake puppet:migrate:populate_hosts RAILS_ENV=production
18 1
</pre>
19 1
20 1
This will create all required settings from your facts.
21 1
22 9 Bryan Taylor
h2. Missing facts
23 9 Bryan Taylor
24 9 Bryan Taylor
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.
25 9 Bryan Taylor
26 9 Bryan Taylor
_/etc/puppet/puppet.conf_
27 9 Bryan Taylor
<pre>
28 9 Bryan Taylor
[master]
29 9 Bryan Taylor
30 9 Bryan Taylor
  storeconfigs=true
31 9 Bryan Taylor
  dbadapter=mysql
32 9 Bryan Taylor
  dbuser= puppetuser
33 9 Bryan Taylor
  dbpassword= puppetpass
34 9 Bryan Taylor
  dbserver= mysql.domain.com
35 9 Bryan Taylor
</pre>
36 9 Bryan Taylor
37 9 Bryan Taylor
38 1
39 1
h2. Not using Puppet storeconfigs
40 1
41 1
h3. Running Foreman on the same machine as the puppetmaster
42 1
43 1
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:
44 1
<pre>
45 1
rake puppet:import:hosts_and_facts RAILS_ENV=production
46 1
</pre>
47 1
48 1
this will import your facts (only new facts) every time you run the script.
49 1
50 1
h3. But I have many puppet masters, or Foreman is on another server
51 1
52 1
h4. Pushing facts through HTTP directly to Foreman
53 1
54 1
Foreman accepts remote puppetmaster sending their nodes facts through http, making it effective way to send facts over WAN.
55 1
56 4 Ohad Levy
the "script":https://github.com/ohadlevy/puppet-foreman/blob/master/foreman/files/push_facts.rb is meant to run on each of your puppetmasters.
57 1
it will scan over all of the new fact files (from its last run) and will send them to foreman.
58 1
59 1
You will need to edit the script and set the Foreman URL (based on where Foreman is located in your setup).
60 1
61 3 Ohad Levy
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.
62 3 Ohad Levy
63 3 Ohad Levy
h4. local file system access to fact yaml files
64 3 Ohad Levy
65 3 Ohad Levy
The previously mentioned  rake task accepts a _dir_ parameter, which means you can tell it to import facts from any directory.
66 3 Ohad Levy
if you store your fact yaml on some network share, or if you want to mount your puppetmaster you can:
67 3 Ohad Levy
<pre>
68 3 Ohad Levy
rake puppet:import:hosts_and_facts dir=/my/dir/with/yaml/files RAILS_ENV=production
69 3 Ohad Levy
</pre>
70 3 Ohad Levy
71 3 Ohad Levy
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