Integrate Puppet to Foreman


Continue with my previous post – Build Foreman as Puppet ENC. Now it’s the time to integrate the Puppet to Foreman.

On the foreman server (foreman.mylab.local):

1) Add the puppet smart proxy

Selection_015

2) Import the environments via the smart proxy

Selection_016

On puppet master (puppet.mylab.local):

1) Create the two executable ruby scripts to push/pull facts to/from foreman:

/etc/puppet/push_facts.rb
/etc/puppet/external_node.rb

2) Add the two entries in the [master] section in  /etc/puppet/puppet.conf

external_nodes = /etc/puppet/external_node.rb
node_terminus = exec

3) Create a cron job (crontab -e) to push the facts to foreman every 30 minutes.

# Push puppet node facts to foreman
30 * * * * /etc/puppet/push_facts.rb

You can manually run it once to check whether it works for you. If it works, you should be able to see the hosts in foreman.

Selection_014

4) Update the sudo file (visudo) to allow foreman-proxy to run some puppet commands.

# Allow foreman-proxy
foreman-proxy ALL = NOPASSWD: /usr/sbin/puppetca *
Defaults:foreman-proxy !requiretty

Defaults:foreman-proxy !requiretty
foreman-proxy ALL = NOPASSWD: /usr/bin/puppet *

5) Create the following file to enable uploading reports to foreman.

/usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb

6) Enable the reports in /etc/puppet/puppet.conf

for puppet master, add the entry in [master] section
reports = foreman, log

for puppet node, add the entry in [agent] section
report = true

Wait for 30 minutes (max), then check the foreman page.

Selection_013

Reference:
http://theforeman.org/manuals/1.1/index.html#3.5.5ImportingFacts
http://projects.theforeman.org/projects/foreman/wiki/Puppet_Reports?version=23
https://github.com/bguerin/puppet-foreman/blob/master/templates/foreman-report.rb.erb

Advertisements

One thought on “Integrate Puppet to Foreman

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s