文章目录

puppet dashboard 配置
Puppet Dashboard可以为你的Puppet环境添加一个图形用户界面(GUI)。Puppet Dashboard可以显示主机上Puppet的运行结果,并且可以提供一个节点分类工具来配置你的主机。
Dashboard是一种运行在Rails上的Ruby应用程序,它还不是可以添加到系统版本中的程序包,但是我们可以从Puppet Labs以RPM或者DEB包的形式获得该软件。我们也可以选择从资源进行安装。

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

yum install -y mysql mysql-devel mysql-server ruby ruby-devel ruby-irb ruby-mysql ruby-rdoc ruby-ri

如果MYSQL 是源码包安装则:yum install -y ruby ruby-devel ruby-irb ruby-mysql ruby-rdoc ruby-ri

安装rubygem 1.3.5 请不要安装1.3.6及更高版本。不支持。。哈哈

http://production.cf.rubygems.org/rubygems/rubygems-1.3.5.tgz
tar xfz rubygems-1.3.5.tgz
cd rubygems-1.3.5
ruby setup.rb `</pre>
使用gem安装rake
gem install rake

安装git 下载dashboard 包
yum -y install git

下载puppet-dashboard
我把它放在/data/www/wwwroot/
mkdir -p /data/www/wwwroot/
cd /data/www/wwwroot/
git clone git://github.com/puppetlabs/puppet-dashboard.git

修改数据配置YML文件
/data/www/wwwroot/puppet-dashboard/config/database.yml
cp database.yml.example database.yml
<pre>`production:
database: root
username: dashboard
password: linuxtone
encoding: utf8
adapter: mysql`</pre>
创建库和表:
1\. 使用rake 创建:
回到   puppet-dashboard目录执行
rake RAILS_ENV=production db:create

2 手动创建
<pre>`CREATE DATABASE dashboard CHARACTER SET utf8;
CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON dashboard.* TO 'dashboard'@'localhost';`</pre>
创建表:rake RAILS_ENV=production db:migrate

我在使用development的时候老是报错。如下:
<pre>`# rake db:migrate db:test:prepare --trace
(in /data/www/wwwroot/puppet-dashboard)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
Access denied for user 'root'@'localhost' (using password: NO) `</pre>
因此我换成了production。大家可以仔细看官网说明。尽管很烂,但也能解决问题

production 与 development 区别:
启动时:
production :Start a production server on port 3000:
./script/server -e production

development:start a development server on port 8080, where the development environment is used by default:
./script/server -p 8080

运行:先查看位置:puppetmasterd --configprint libdir
<pre>`cp ext/puppet/puppet_dashboard.rb  /var/lib/puppet/reports/
chmod 644 /var/lib/puppet/reports/puppet_dashboard.rb
#more puppet_dashboard.rb
HOST = 'localhost'  #主机
PORT = 3000    #启动端口 `</pre>
导入:Import existing reports 详见官网
rake RAILS_ENV=production reports:import REPORT_DIR=/path/to/your/reports
本例:rake RAILS_ENV=production reports:import REPORT_DIR=/var/lib/puppet/reports/

注:/var/lib/puppet/reports/ 为puppet.conf 里vardir 的定义目录

配置puppetmaster
<pre>`[master]
reports = http, store
reporturl = http://IP:3000/reports
modulepath = /etc/puppet/modules`</pre>
puppetclient
<pre>`server = puppetmaster.linuxtone.org
listen = true
report = true
runinterval = 10`</pre>
# more /etc/init.d/puppet-dashboard  注意修改脚本里的IP
<pre>`#!/bin/bash
# Description: Puppet Dashboard init.d script

# Get function from functions library
. /etc/init.d/functions

# Start the service Puppet Dashboard
start() {
echo -n "Starting Puppet Dashboard: "
/usr/bin/ruby /data/www/wwwroot/puppet-dashboard/script/server -e production -b IP &
### Create the lock file ###
touch /var/lock/subsys/puppetdb
success $"Puppet Dashboard startup"
echo
}

# Restart the service Puppet Dashboard
stop() {
echo -n "Stopping Puppet Dashboard: "
kill -9 `ps ax | grep "/usr/bin/ruby /data/www/wwwroot/puppet-dashboard/script/server" | grep -v grep | awk '{ print $1 }' ` 
### Now, delete the lock file ###
rm -f /var/lock/subsys/puppetdb
success $"Puppet Dashboard shutdown"
echo
}

### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status Puppet DB
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac

exit 0

chmod 755 /etc/init.d/puppet-dashboard
/etc/init.d/puppet-dashboard start

参考
http://docs.puppetlabs.com/guides/installing_dashboard.html

文章目录