技术交流:www.kisspuppet.com puppet实战 欢迎puppet爱好者加入自动化运维交流总QQ群:296934942
Puppet Dasshboard是由支持Puppet开发的公司Puppetlabs创建的,是Ruby on Rails程序。可以作为一个ENC(外部节点分类器)以及一个报告工具,并且正在逐渐成为一个包含许多Puppet新功能的集成界面,例如审计和资源管理功能。
Puppet Dashboard是一个Ruby on Rails程序,用于显示Puppet master和agent的相关信息。它允许你查看从一个或多个Puppet master汇总的图形和报告数据。它同时从一个或者多个Puppet master上收集来自于Puppet agent的资产数据(主机的Fact和其他信息)。最后,它能作为一个ENC来配置Puppet节点,并指定这些节点上的类和参数。 1 前期准备工作
Puppet Dashboard(1.2.3)程序目前版本只能安装在Ruby 1.8.x(Dashboard还不能工作在1.9.x下或者更新的版本下),只支持MySQL作为数据库后端。
Rake version 0.8.3 or newer
MySQL database server version 5.x
Ruby-MySQL bindings version 2.7.x or 2.8.x 备注:更多详细信息请参考:http://docs.puppetlabs.com/dashboard/ 2 安装相关软件包
[root@puppetserver nodes]# yum install ruby-mysql mysql-server puppet-dashboard3 配置Dashboard(包括与数据库的结合部分) 3.1 创建管理Dashboard的MySQL数据库账号并授权
[root@puppetserver rpms]# /etc/rc.d/init.d/mysqld restart
[root@puppetserver ~]# chkconfig mysqld on
[root@puppetserver puppet-dashboard]# rake RAILS_ENV=production db:migrate #环境变量RAILS_ENV=production告诉Ruby on Rails我们工作在生产环境。每次你运行一个rake命令都需要使用合适的环境值来设置RAILS_ENV环境变量 3.5 查看是否导入成功
[root@puppetserver puppet-dashboard]# mysql -udashboard -p123.com
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection>
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use dashboard;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Puppet::Reports.register_report(:http) do
desc <<-DESC
Send report information via HTTP to the `reporturl`. Each host sends
its report as a YAML dump and this sends this YAML to a client via HTTP POST.
The YAML is the body of the request.
DESC
def process
url = URI.parse(Puppet[:reporturl])
req = Net::HTTP::Post.new(url.path)
req.body = self.to_yaml
req.content_type = "application/x-yaml"
Net::HTTP.new(url.host, url.port).start {|http|
response = http.request(req)
unless response.kind_of?(Net::HTTPSuccess)
Puppet.err "Unable to submit report to #{Puppet[:reporturl].to_s} [#{response.code}] #{response.msg}"
end
}
end
end 7.2.2 自定义摘要报告处理器 7.2.2.1 进入reports目录编写自定义summary.rb报告处理器
[root@puppetserver ~]# cd /usr/lib/ruby/site_ruby/1.8/puppet/reports
[root@puppetserver reports]# vim summary.rb
require 'puppet'
Puppet::Reports.register_report(:summary) do
desc <<-DESC
Send summary report information to the report directory.
DESC
def process
client = self.host
summary = self.summary
dir = File.join(Puppet[:reportdir],client)
client = self.host
file = "summary.txt"
destination = File.join(dir,file)
File.open(destination,"w") do |f|
f.write(summary)
end
end
end 7.2.2.2 将报告处理器的名字加入puppet.conf中,并重新启动httpd服务
[root@puppetserver ~]# vim /etc/puppet/puppet.conf
[main]