puppet-dashboard 安装(草稿)

接着上面的puppet安装一文,虽然puppet会很努力的工作,但还有个问题,我们想了解puppet节点的运行情况,也就是回馈,因为编写puppet语法规则难免出错。但是report目录下的yaml 文件又不具有可读性,客户端很多则邮件又会被淹没,于是这就有了dashboard。

dashboard 跟cacti 有点类似,都使用mysql作为后端数据库。
沿袭前面文章的环境
centos 6
服务端 puppet .test.org
客户端 apache01.test.org
已经配置好了http + passenger


安装dashboard

yum install puppetlabs-release
yum install puppet-dashboard mysql-server ruby-mysql
配置mysql数据库
# service mysqld start
# mysql -u root -p
mysql> CREATE DATABASE dashboard_production CHARACTER SET utf8;
>CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'dashboard';
>GRANT ALL PRIVILEGES ON dashboard_production.* TO 'dashboard'@'localhost';
> flush privileges;


编辑/usr/share/puppet-dashboard/config/database.yml,修改如下

production:
  database: dashboard_production
  username: dashboard
  password: dashboard
  encoding: utf8
  adapter: mysql
导入数据
# cd /usr/share/puppet-dashboard/
# rake gems:refresh_specs
# rake RAILS_ENV=production db:create
# rake RAILS_ENV=production db:migrate


启动puppet-dashboard

chmod 666 /usr/share/puppet-dashboard/log/production.log
service  puppet-dashboard start


这样,puppet-dashboard 就会监听在本地3000端口,使用的是ruby自带的http服务器webrick,可以通过web浏览了。

apache作为前端

配置httpd虚拟主机

cp /usr/share/puppet-dashboard/ext/passenger/dashboard-vhost.conf /etc/httpd/conf.d/dashboard.conf

配置文件同样是给debian/ubuntu 用的,需要做一些修改


1、将日志选项路径 /var/log/apache2 改为/var/log/httpd
2、取个puppet主机的子域名 dashboard.puppet.test.org
3、模块路径由
  
  
  
  
  1. /var/lib/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so  

修改为
  
  
  
  
  1. /usr/lib64/httpd/modules/mod_passenger.so

4、passenger路径替换,将
  
  
  
  
  1. /var/lib/gems/1.8/gems/passenger-2.2.11

修改为
  
  
  
  
  1. /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12

(版本号可能有差异,请事先查看是否存在类似的目录)
(其实之前已经配置了passenger,所以这行导入模块可以注释掉)
修改后大概就是这个样子(前3行可以注释掉)
  
  
  
  
  1. # LoadModule passenger_module /usr/lib64/httpd/modules/mod_passenger.so

  2. # PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12

  3. # PassengerRuby /usr/bin/ruby

  4. # you may want to tune these settings

  5. PassengerHighPerformance on

  6. PassengerMaxPoolSize 12

  7. PassengerPoolIdleTime 1500

  8. # PassengerMaxRequests 1000

  9. PassengerStatThrottleRate 120

  10. RailsAutoDetect On

  11. <VirtualHost *:80>

  12.        ServerName dashboard.puppet.test.org

  13.        DocumentRoot /usr/share/puppet-dashboard/public/

  14. <Directory /usr/share/puppet-dashboard/public/>

  15.                Options None

  16.                Order allow,deny

  17.                allow from all

  18. </Directory>

  19.  ErrorLog /var/log/httpd/dashboard.puppet.test.org_error.log

  20.  LogLevel warn

  21.  CustomLog /var/log/httpd/dashboard.puppet.test.org_access.log combined

  22.  ServerSignature On

重启httpd
  
  
  
  
  1. service httpd restart

实时报告
设置puppet客户端每次执行完任务后立即报告给dashboard
在apache01.test.org上设置puppet客户端
  
  
  
  
  1. [agent]

  2. report = true

在puppet.test.org 上设置puppet服务端
  
  
  
  
  1. [master]

  2. reports = store,http

  3. reporturl = http://dashboard.puppet.test.org:80/reports

导入现有yml文件报告
  
  
  
  
  1. #rake RAILS_ENV=production reports:import REPORT_DIR=/var/lib/puppet/

最后一步
  
  
  
  
  1. cp /usr/share/puppet-dashboard/ext/puppet/puppet_dashboard.rb /var/lib/puppet/reports/

启动服务
  
  
  
  
  1. # /etc/init.d/puppet-dashboard start

  2. # /etc/init.d/puppet-dashboard-workers start

你可能感兴趣的:(dashboard,puppet)