PUPPET-安装配置Dashboard显示和解析Puppet报告


简介:

Puppet Dashboard 是一个Ruby on Rails程序,用于显示Puppet masteragent的相关信息,有一个web控制台,能够更好的管理puppet


效果展示图:

135040720.png



一、 Puppet Dashboard 安装环境介绍


系统环境:

操作系统:Centos 5.4

内核:2.6.18-164.el5

位数:x86_64


软件版本:

Puppet:2.7.21

Facter:1.7.1

Ruby:1.8.5


二、Puppet dashboard 安装过程

1、安装依赖包


安装rvm


rvm是一个命令行工具,可以提供一个便捷的多版本ruby环境管理和切换

官方网站:https://rvm.io/

# \curl -sSL https://get.rvm.io | bash -s stable

* 错误信息

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:

error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

More details here: http://curl.haxx.se/docs/sslcerts.html


curl performs SSL certificate verification by default, using a "bundle"

of Certificate Authority (CA) public keys (CA certs). The default

bundle is named curl-ca-bundle.crt; you can specify an alternate file

using the --cacert option.

If this HTTPS server uses a certificate signed by a CA represented in

the bundle, the certificate verification probably failed due to a

problem with the certificate (it might be expired, or the name might

not match the domain name in the URL).

If you'd like to turn off curl's verification of the certificate, use

the -k (or --insecure) option.


这是由于证书的缘故导致,我们可以跳过证书验证,使用-k参数

操作如下:

# \curl -sSL https://get.rvm.io | bash -s stable


* 执行上述操作后,出现新的错误信息,如下

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:

error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

More details here: http://curl.haxx.se/docs/sslcerts.html


curl performs SSL certificate verification by default, using a "bundle"

of Certificate Authority (CA) public keys (CA certs). The default

bundle is named curl-ca-bundle.crt; you can specify an alternate file

using the --cacert option.

If this HTTPS server uses a certificate signed by a CA represented in

the bundle, the certificate verification probably failed due to a

problem with the certificate (it might be expired, or the name might

not match the domain name in the URL).

If you'd like to turn off curl's verification of the certificate, use

the -k (or --insecure) option.


Could not download 'https://bitbucket.org/mpapis/rvm/get/stable.tar.gz', you can read more about it here:

https://rvm.io/support/fixing-broken-ssl-certificates/

To continue in insecure mode run 'echo insecure >> ~/.curlrc'.

错误原因是没有在本地变量中定义insecure 导致,手动定义变量,即可解决,以下为rvm安装步骤:

# echo insecure >> ~/.curlrc    #定义变量

# \curl -sSL https://get.rvm.io | bash -s stable     #安装rvm

# reboot     #重启机器

重启机器后,rvm命令可以使用则rvm安装成功。


安装ruby

机器现有ruby版本为1.8.5,本次需要使用ruby版本为1.8.7,我们已完成rvm,通过rvm命令来安装ruby

使用rvm时,请挂载光盘,保证yum可用,安装ruby1.8.7时,会通过yum安装依赖包gcc-c++, readline-devel, libyaml-devel, libffi-devel, autoconf, automake, libtool, bison。。。

# rvm install 1.8.7   #安装ruby

# ruby -v   #查看ruby版本

# rvm use 1.8.7 --default   #1.8.7定义为默认ruby


源码包下载地址:

http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz


安装rake


操作步骤如下:

# wget http://files.rubyforge.vm.bytemark.co.uk/rake/rake-0.8.7.tgz

# tar -zxvf rake-0.8.7.tgz

# cd rake-0.8.7

# ruby install.rb


安装rubygems

安装过rubygem会自动安装,但是在安装dashboard时需要考虑到gem版本兼容问题,所以在这里安装rubygems 1.8.11版本,以下为安装步骤:


# wget http://files.rubyforge.vm.bytemark.co.uk/rubygems/rubygems-1.8.11.tgz

# tar -zxvf rubygems-1.8.11.tgz

# cd rubygems-1.8.11

# ruby setup.rb


安装MySQL


采用yum方式安装


# yum install mysql*


安装Ruby-MySQL


通过gem安装

# gem install mysql


2、安装puppet dashboard

安装puppet-dashboard

操作步骤如下:

# wget http://puppetlabs.com/downloads/dashboard/puppet-dashboard-1.2.0.tar.gz

# tar -zxvf puppet-dashboard-1.2.0.tar.gz

# mv puppet-dashboard-1.2.0 /etc/puppet-dashboard

# groupadd puppet-dashboard

# useradd -g puppet-dashboard puppet-dashboard

# chown -R puppet-dashboard:puppet-dasboard /etc/puppet-dashboard/

# cd /etc/puppet-dashboard/config/

# cp database.yml.example database.yml

# cp settings.yml.example settings.yml


创建数据库

mysql> CREATE DATABASE dashboard CHARACTER SET utf8;

mysql> CREATE USER 'dashboard'@'localhost' IDENTIFIED BY '123';

mysql> GRANT ALL PRIVILEGES ON dashboard.* TO 'dashboard'@'localhost';

mysql> exit


修改datebase.yml

production:

 database: dashboard

 username: dashboard

 password: 123

 encoding: utf8

 adapter: mysql


修改mysql配置文件

修改单行的最大容量

# vi /etc/my.cnf

mysqld中加入下行

max_allowed_packet = 32M

# service mysqld restart


创建数据库表

/etc/puppet-dashboard/config 必须在此目录下:

# rake RAILS_ENV=production db:migrate


* 报错信息如下:

Gem::SourceIndex#add_spec called from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91.

rake aborted!

no such file to load -- rdoc/task

/etc/puppet-dashboard/Rakefile:9

(See full trace by running task with --trace)


解决方法:

# gem install rdoc


安装完成后,再次创建数据库表,执行rake命令


* 报错信息:

Gem::SourceIndex#add_spec called from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91.

rake aborted!

Could not find rack (~> 1.1.0) amongst [json-1.8.1, mysql-2.9.1, rdoc-4.0.1]


(See full trace by running task with --trace)


上述报错信息,是由于rake版本导致,解决方法如下:


# gem install rack --version=1.1.2


再次创建数据库表,已经可以顺利完成。


测试dashboard正常工作


# cd ..

# script/server -e production

#通过浏览器进行访问


http://192.168.19.184:3000/


访问到dashboard页面说明已经安装完成。


三、配置Puppet dashboard

1.配置puppetdashboard提交数据


Agent操作:

# vi /etc/puppet/puppet.conf

[agent]

report = true


Master 操作:

# vi /etc/puppet/puppet.conf

reports = store,http

reporturl = http://localhost:3000/reports/upload

#配置ENC

node_terminus = exec

external_nodes = /usr/bin/env PUPPET_DASHBOARD_URL=http://localhost:3000 /etc/puppet-dashboard/bin/external_node


# service puppetmaster restart  #重启服务


监控

# env RAILS_ENV=production script/delayed_job -p dashboard -n 1 -m start


运行任务


rake RAILS_ENV=production jobs:work


重新打开浏览器,就可以看到reports



四、参考文章


http://downloads.puppetlabs.com/docs/dashboardmanual.pdf