分类: LINUX
2010-12-13 19:23:13
Dashboard是一种运行在Rails上的Ruby应用程序,它还不是可以添加到系统版本中的程序包,但是我们可以从Puppet Labs以RPM或者DEB包的形式获得该软件。我们也可以选择从资源进行安装。
首先请安装以下包:
* [Ruby]() or [Ruby Enterprise Edition]() programming language interpreter, version 1.8.4 to 1.8.7, but not 1.9.x
* [Rake]() build tool for Ruby, version 0.8.3 or newer
* [MySQL]() database server 5.x
* [Ruby-MySQL]() bindings 2.7.x or 2.8.x
* [Rubygems]() package manager to easily install Ruby libraries
1、yum install -y mysql mysql-devel ruby ruby-devel ruby-irb ruby-mysql ruby-rdoc ruby-ri
2、yum -y install rake rubygems rubygems-rake
3、安装mysql-server 可以直接rpm安装也可以下载源码包编译安装并启动
4、下载解压缩Puppet dashboard
wget
tar -zxf puppet-dashboard-1.0.4.tgz
5、修改数据库连接配置文件如下:
[root@test-sx29 log]# cat dashboard/config/database.yml
development:
adapter: mysql
database: dashboard
username: test
password: 123456
encoding: utf8
host: localhost
6、在数据库创建dashboard
CREATE DATABASE dashboard CHARACTER SET utf8;
CREATE USER IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON dashboard.* TO ;
7、初始化数据库
rake RAILS_ENV=production db:migrate
8、把dashboard整个目录移动到/usr/local (个人习惯)
9、修改客户端puppet.conf文件,在[puppetd]添加report = true 一行,重启puppet
service puppet restart
10、确认puppet master运行库文件位置
puppetmasterd --configprint libdir
如果路径为/var/lib/puppet/lib,就执行以下命令:
mkdir -p /var/lib/puppet/lib/puppet/reports/
11、cp /usr/local/dashboard/ext/puppet/puppet_dashboard.rb /var/lib/puppet/lib/puppet/reports
chmod 755 /var/lib/puppet/lib/puppet/reports/puppet_dashboard.rb
修改文件内容如下:
require 'puppet'
HOST = '0.0.0.0'
PORT = 80
Puppet::Reports.register_report(:puppet_dashboard) do
desc "Send report information to Puppet-Dashboard"
def process
Net::HTTP.start(HOST, PORT) do |conn|
conn.post "/reports", "report=" + CGI.escape(self.to_yaml)
end
end
end
12、修改puppet master的配置文件,在[puppetmasterd]添加一行:
reports = puppet_dashboard,并重启master
13、如果时区显示有问题,在config/enviroment.rb文件中修改:
config.time_zone = 'Beijing'
14、启动web
./script/server -p 80
15、如果没有意外,dashboard将会接收到新的report,访问 进入web界面。
16、如果想将以前的report导入,在dashboard目录运行:rake reports:import,
如果reportdir不是/var/lib/puppet/reports则运行:
rake reports:import REPORT_DIR=/path/to/your/reports