Foreman -- Reporting

1,046 views
Skip to first unread message

CraftyTech

unread,
Jun 9, 2010, 11:09:02 AM6/9/10
to Puppet Users
Hello All,

I don't seem to be able to get reports to display on the foreman
interface. I copied extras/puppet/foreman/files/foreman-report.rb to /
usr/lib/ruby/site_ruby/1.8/puppet/reportsforeman.rb, instead of /usr/
lib/ruby/1.8/puppet/reports/foreman.rb. Config: Centos5.4, Apache/
Passenger, Puppet 0.25.4.

The reports are coming from the clients, because I can see them
in /var/lib/puppet/reports. I just don't seem to be able to display
them on Foreman. Here's my puppet.conf:

[main]
vardir = /var/lib/puppet
logdir = /var/log/puppet
rundir = /var/run/puppet
reports= log, foreman

[puppetmasterd]
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY
modulepath = $confdir/modules
#reports=log, foreman
storeconfigs = true
dbadapter = mysql
dbuser = app_puppet
dbpassword = password
dbserver = localhost
dbsocket = /sql/mysql/mysql.sock
rrddir=/var/lib/puppet/rrd
rrdinterval=$runinterval
rrdgraph=true

[puppetd]
classfile = $vardir/classes.txt
report = true
localconfig = $vardir/localconfig

What am I missing here? Thanks,

Henry

CraftyTech

unread,
Jun 9, 2010, 11:13:23 AM6/9/10
to Puppet Users
Correction: I copied the foreman.rb to /usr/lib/ruby/site_ruby/1.8/
puppet/reports/foreman.rb from extras/puppet/foreman/files/foreman-
report.rb. The instructions called for the file to be copied to /usr/
lib/ruby/1.8/puppet/reports, but that's not the directory structure
that I have. I also made the file executable.

Thanks,

Ryan

unread,
Jun 9, 2010, 11:19:11 AM6/9/10
to Puppet Users
On RHEL, using the rpm packages for foreman and puppet, I had to copy /
usr/share/foreman/extras/puppet/foreman/files/foreman-report.rb to /
usr/lib/ruby/site_ruby/1.8/puppet/foreman.rb and everything works
swimmingly.

Also, uncomment #reports=log, foreman in puppetmasterd... it may still
work in main, but I put it in the puppetmasterd stanza.

Hope that helps you too!

--Ryan

Jonathan A. Booth

unread,
Jun 9, 2010, 11:14:13 AM6/9/10
to puppet...@googlegroups.com
For what it is worth, to solve a similar problem with dashboard
(distributing puppet_dashboard.rb for reporting), I just stuck it in
modules/dashboard/lib/puppet_dashboard.rb with puppet.conf:
pluginsync=true. Then puppet distributes it automatically into a lib
directory and things work nice and happy.

CraftyTech

unread,
Jun 9, 2010, 2:52:34 PM6/9/10
to Puppet Users
My issue is basically, that I'm running foreman under passenger, and
this config seems to break reporting. Yesterday,I was using webbrick
and it was working fine, with the URL of foreman.rb pointing to
http://host:3000. Today with passenger, I'm trying to point it to
either http://host or https://host. Neither way has worked so far.
Again, the reports are coming in, I'm just not able to display them
under foreman.

Thanks,

Jonathan A. Booth

unread,
Jun 9, 2010, 3:18:50 PM6/9/10
to puppet...@googlegroups.com
With reports=log,foreman you'll see them under /var/lib/puppet/reports
even if they aren't actually getting to foreman itself. Executability of
foreman.rb won't factor in this working or not.

The code in foreman.rb is probably connecting directly to foreman on
http://(local?)host:3000. You may need to modify that file to connect to
http://host:80 or via https. Alternately you could just have passenger
listen to said port (localhost:3000).

Note I don't strictly know that's true of Foreman. I'm guessing, based
on my experiences with dashboard and passenger.

Jacob Hunt

unread,
Jun 9, 2010, 4:02:34 PM6/9/10
to puppet...@googlegroups.com
What does your apache conf look like for foreman and the reports?


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.


Message has been deleted
Message has been deleted

CraftyTech

unread,
Jun 9, 2010, 4:29:03 PM6/9/10
to Puppet Users
/etc/httpd/conf.d/foreman.conf:
<VirtualHost *:443>
ServerName hostnameXYZ
ServerAlias foreman

RailsAutoDetect On
DocumentRoot /var/www/html
RailsBaseURI /foreman

# Use puppet certi ficates for SSL
SSLEngine on
SSLCertificateFile /var/lib/puppet/ssl/certs/
hostnameXYZ.pem
SSLCertificateKeyFile /var/lib/puppet/ssl/private_keys/
hostnameXYZ.pem
SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem
SSLCACertificateFile /var/lib/puppet/ssl/ca/ca_crt.pem
SSLCARevocationFile /var/lib/puppet/ssl/ca/ca_crl.pem
SSLVerifyClient optional
SSLVerifyDepth 3
SSLOptions +StdEnvVars

</VirtualHost>

/usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb:
# copy this file to your report dir - e.g. /usr/lib/ruby/1.8/puppet/
reports/
# add this report in your puppetmaster reports - e.g, in your
puppet.conf add:
# reports=log, foreman # (or any other reports you want)

# URL of your Foreman installation
$foreman_url="https://hostnameXYZ/foreman"

require 'puppet'
require 'net/http'
require 'uri'

Puppet::Reports.register_report(:foreman) do
Puppet.settings.use(:reporting)
desc "Sends reports directly to Foreman"

def process
begin
uri = URI.parse($foreman_url)
http = Net::HTTP.new(uri.host, uri.port)
if uri.scheme == 'https' then
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
req = Net::HTTP::Post.new("/reports/create?format=yml")
req.set_form_data({'report' => to_yaml})
response = http.request(req)
rescue Exception => e
raise Puppet::Error, "Could not send report to Foreman at
#{$foreman_url}/reports/create?format=yml: #{e}"
end
end
end
~

/etc/puppet/puppet.conf:
[main]
vardir = /var/lib/puppet
logdir = /var/log/puppet
rundir = /var/run/puppet
reports= log,foreman,store
pluginsync = true

[puppetmasterd]
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY
modulepath = $confdir/modules
reportdir = /var/lib/puppet/reports
storeconfigs = true
dbadapter = mysql
dbuser = puppet
dbpassword = password
dbserver = localhost
dbsocket = /sql/mysql/mysql.sock
rrddir=/var/lib/puppet/rrd
rrdinterval=$runinterval
rrdgraph=true

[puppetd]
classfile = $vardir/classes.txt
report = true
localconfig = $vardir/localconfig
*****************************************
The reports come in fine under /var/lib/puppet/reports. The only
piece that's not working is the reports on foreman. Any suggestions?

Thanks,

Henry

On Jun 9, 4:02 pm, Jacob Hunt <jacob.r.h...@gmail.com> wrote:
> What does your apache conf look like for foreman and the reports?
>
> > puppet-users...@googlegroups.com<puppet-users%2Bunsu...@googlegroups.com>
> > .

Jacob Hunt

unread,
Jun 9, 2010, 4:35:28 PM6/9/10
to puppet...@googlegroups.com
Looks like my config, except I added the following to see my reports

  Alias /report /var/lib/puppet/rrd/
  <Directory /var/lib/puppet/rrd/>
    PassengerEnabled off
    Options Indexes
    Order deny,allow
    Allow from all
  </Directory>


On Wed, Jun 9, 2010 at 2:15 PM, CraftyTech <hmme...@gmail.com> wrote:
/etc/httpd/conf.d/foreman.conf:
<VirtualHost *:443>
 ServerName hostnameXYZ
 ServerAlias foreman

 RailsAutoDetect On
 DocumentRoot /var/www/html
 RailsBaseURI /foreman

 # Use puppet certi    ficates for SSL
 SSLEngine on
 SSLCertificateFile      /var/lib/puppet/ssl/certs/
hpjs01.isn.instinet.com.pem
 SSLCertificateKeyFile   /var/lib/puppet/ssl/private_keys/
hpjs01.isn.instinet.com.pem
[main]
   vardir = /var/lib/puppet
   logdir = /var/log/puppet
   rundir = /var/run/puppet
   reports= log,foreman,store
   pluginsync = true


[puppetmasterd]
   ssl_client_header = SSL_CLIENT_S_DN
   ssl_client_verify_header = SSL_CLIENT_VERIFY
   modulepath = $confdir/modules
   reportdir = /var/lib/puppet/reports

   storeconfigs = true
   dbadapter = mysql
   dbuser = app_puppet
   dbpassword = CoNf1Gpupp3T

   dbserver = localhost
   dbsocket = /sql/mysql/mysql.sock
   rrddir=/var/lib/puppet/rrd
   rrdinterval=$runinterval
   rrdgraph=true

[puppetd]
   classfile = $vardir/classes.txt
   report = true
   localconfig = $vardir/localconfig
*****************************************
The reports come in fine under /var/lib/puppet/reports.  The only
piece that's not working is the reports on foreman. Any suggestions?

Thanks,

Henry


On Jun 9, 4:02 pm, Jacob Hunt <jacob.r.h...@gmail.com> wrote:
> What does your apache conf look like for foreman and the reports?
>

Chuck

unread,
Jun 9, 2010, 8:22:11 PM6/9/10
to Puppet Users
What happens if you have foreman listen say on port 3000 with
passenger and have ssl disabled?

CraftyTech

unread,
Jun 10, 2010, 9:19:40 AM6/10/10
to Puppet Users
Thanks for responses everyone. It's fine now. Using the subdir was
hurting me, i.g, RailsBaseURI /foreman, as I couldn't put it in the
url field of foreman.rb. Now that I took it off, all needed to do was
to redirect the url to https://host:443. It works fine now.

Cheers,
Henry
Reply all
Reply to author
Forward
0 new messages