Puppet Facts

Version 11 (Ohad Levy, 10/11/2011 03:43 am)

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