接着上面的puppet安裝一文,雖然puppet會很努力的工作,但還有個問題,我們想了解puppet節點的運作情況,也就是回饋,因為編寫puppet文法規則難免出錯。但是report目錄下的yaml 檔案又不具有可讀性,用戶端很多則郵件又會被淹沒,于是這就有了dashboard。
dashboard 跟cacti 有點類似,都使用mysql作為後端資料庫。
沿襲前面文章的環境
centos 6
服務端 puppet .test.org
用戶端 apache01.test.org
已經配置好了http + passenger
安裝dashboard
1
2
<code>yum </code><code>install</code> <code>puppetlabs-release</code>
<code>yum </code><code>install</code> <code>puppet-dashboard mysql-server ruby-mysql</code>
配置mysql資料庫
3
4
5
6
<code># service mysqld start</code>
<code># mysql -u root -p</code>
<code>mysql> CREATE DATABASE dashboard_production CHARACTER SET utf8;</code>
<code>>CREATE USER </code><code>'dashboard'</code><code>@</code><code>'localhost'</code> <code>IDENTIFIED BY </code><code>'dashboard'</code><code>;</code>
<code>>GRANT ALL PRIVILEGES ON dashboard_production.* TO </code><code>'dashboard'</code><code>@</code><code>'localhost'</code><code>;</code>
<code>> flush privileges;</code>
編輯/usr/share/puppet-dashboard/config/database.yml,修改如下
<code>production:</code>
<code> </code><code>database: dashboard_production</code>
<code> </code><code>username: dashboard</code>
<code> </code><code>password: dashboard</code>
<code> </code><code>encoding: utf8</code>
<code> </code><code>adapter: mysql</code>
導入資料
<code># cd /usr/share/puppet-dashboard/</code>
<code># rake gems:refresh_specs</code>
<code># rake RAILS_ENV=production db:create</code>
<code># rake RAILS_ENV=production db:migrate</code>
啟動puppet-dashboard
<code>chmod</code> <code>666 </code><code>/usr/share/puppet-dashboard/log/production</code><code>.log</code>
<code>service puppet-dashboard start</code>
這樣,puppet-dashboard 就會監聽在本地3000端口,使用的是ruby自帶的http伺服器webrick,可以通過web浏覽了。
apache作為前端
配置httpd虛拟主機
<code>cp</code> <code>/usr/share/puppet-dashboard/ext/passenger/dashboard-vhost</code><code>.conf </code><code>/etc/httpd/conf</code><code>.d</code><code>/dashboard</code><code>.conf</code>
配置檔案同樣是給debian/ubuntu 用的,需要做一些修改
1、将日志選項路徑 /var/log/apache2 改為/var/log/httpd
2、取個puppet主機的子域名 dashboard.puppet.test.org
3、子產品路徑由
/var/lib/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
修改為
/usr/lib64/httpd/modules/mod_passenger.so
4、passenger路徑替換,将
/var/lib/gems/1.8/gems/passenger-2.2.11
/usr/lib/ruby/gems/1.8/gems/passenger-3.0.12
(版本号可能有差異,請事先檢視是否存在類似的目錄)
(其實之前已經配置了passenger,是以這行導入子產品可以注釋掉)
修改後大概就是這個樣子(前3行可以注釋掉)
# LoadModule passenger_module /usr/lib64/httpd/modules/mod_passenger.so
# PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12
# PassengerRuby /usr/bin/ruby
# you may want to tune these settings
PassengerHighPerformance on
PassengerMaxPoolSize 12
PassengerPoolIdleTime 1500
# PassengerMaxRequests 1000
PassengerStatThrottleRate 120
RailsAutoDetect On
<VirtualHost *:80>
ServerName dashboard.puppet.test.org
DocumentRoot /usr/share/puppet-dashboard/public/
<Directory /usr/share/puppet-dashboard/public/>
Options None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/dashboard.puppet.test.org_error.log
LogLevel warn
CustomLog /var/log/httpd/dashboard.puppet.test.org_access.log combined
ServerSignature On
重新開機httpd
service httpd restart
實時報告
設定puppet用戶端每次執行完任務後立即報告給dashboard
在apache01.test.org上設定puppet用戶端
[agent]
report = true
在puppet.test.org 上設定puppet服務端
[master]
reports = store,http
reporturl = http://dashboard.puppet.test.org:80/reports
導入現有yml檔案報告
#rake RAILS_ENV=production reports:import REPORT_DIR=/var/lib/puppet/
最後一步
cp /usr/share/puppet-dashboard/ext/puppet/puppet_dashboard.rb /var/lib/puppet/reports/
啟動服務
# /etc/init.d/puppet-dashboard start
# /etc/init.d/puppet-dashboard-workers start
本文轉自 紫色葡萄 51CTO部落格,原文連結:http://blog.51cto.com/purplegrape/949457,如需轉載請自行聯系原作者