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
2) Import the environments via the smart proxy
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.
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.
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
One thought on “Integrate Puppet to Foreman”