PUPPET-安裝配置Dashboard顯示和解析Puppet報告
簡介:
Puppet Dashboard 是一個Ruby on Rails程序,用於顯示Puppet master和agent的相關信息,有一個web控制檯,能夠更好的管理puppet。
效果展示圖:
一、 Puppet Dashboard 安裝環境介紹
系統環境:
操作系統:Centos 5.4
內核:2.6.18-164.el5
位數:x86_64
軟件版本:
Puppet:2.7.21
Facter:1.7.1
Ruby:1.8.5
二、Puppet dashboard 安裝過程
1、安裝依賴包
安裝rvm
rvm是一個命令行工具,可以提供一個便捷的多版本ruby環境管理和切換
官方網站:https://rvm.io/
# \curl -sSL https://get.rvm.io | bash -s stable |
* 錯誤信息
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). The default bundle is named curl-ca-bundle.crt; you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. |
這是由於證書的緣故導致,我們可以跳過證書驗證,使用-k參數
操作如下:
# \curl -sSL https://get.rvm.io | bash -s stable |
* 執行上述操作後,出現新的錯誤信息,如下
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). The default bundle is named curl-ca-bundle.crt; you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. Could not download 'https://bitbucket.org/mpapis/rvm/get/stable.tar.gz', you can read more about it here: https://rvm.io/support/fixing-broken-ssl-certificates/ To continue in insecure mode run 'echo insecure >> ~/.curlrc'. |
錯誤原因是沒有在本地變量中定義insecure 導致,手動定義變量,即可解決,以下爲rvm安裝步驟:
# echo insecure >> ~/.curlrc #定義變量 # \curl -sSL https://get.rvm.io | bash -s stable #安裝rvm # reboot #重啓機器 |
重啓機器後,rvm命令可以使用則rvm安裝成功。
安裝ruby
機器現有ruby版本爲1.8.5,本次需要使用ruby版本爲1.8.7,我們已完成rvm,通過rvm命令來安裝ruby
使用rvm時,請掛載光盤,保證yum可用,安裝ruby1.8.7時,會通過yum安裝依賴包gcc-c++, readline-devel, libyaml-devel, libffi-devel, autoconf, automake, libtool, bison。。。
# rvm install 1.8.7 #安裝ruby # ruby -v #查看ruby版本 # rvm use 1.8.7 --default #將1.8.7定義爲默認ruby |
源碼包下載地址:
http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz |
安裝rake
操作步驟如下:
# wget http://files.rubyforge.vm.bytemark.co.uk/rake/rake-0.8.7.tgz # tar -zxvf rake-0.8.7.tgz # cd rake-0.8.7 # ruby install.rb |
安裝rubygems
安裝過ruby,gem會自動安裝,但是在安裝dashboard時需要考慮到gem版本兼容問題,所以在這裏安裝rubygems 1.8.11版本,以下爲安裝步驟:
# wget http://files.rubyforge.vm.bytemark.co.uk/rubygems/rubygems-1.8.11.tgz # tar -zxvf rubygems-1.8.11.tgz # cd rubygems-1.8.11 # ruby setup.rb |
安裝MySQL
採用yum方式安裝
# yum install mysql* |
安裝Ruby-MySQL
通過gem安裝
# gem install mysql |
2、安裝puppet dashboard
安裝puppet-dashboard
操作步驟如下:
# wget http://puppetlabs.com/downloads/dashboard/puppet-dashboard-1.2.0.tar.gz # tar -zxvf puppet-dashboard-1.2.0.tar.gz # mv puppet-dashboard-1.2.0 /etc/puppet-dashboard # groupadd puppet-dashboard # useradd -g puppet-dashboard puppet-dashboard # chown -R puppet-dashboard:puppet-dasboard /etc/puppet-dashboard/ # cd /etc/puppet-dashboard/config/ # cp database.yml.example database.yml # cp settings.yml.example settings.yml |
創建數據庫
mysql> CREATE DATABASE dashboard CHARACTER SET utf8; mysql> CREATE USER 'dashboard'@'localhost' IDENTIFIED BY '123'; mysql> GRANT ALL PRIVILEGES ON dashboard.* TO 'dashboard'@'localhost'; mysql> exit |
修改datebase.yml
production: database: dashboard username: dashboard password: 123 encoding: utf8 adapter: mysql |
修改mysql配置文件
修改單行的最大容量
# vi /etc/my.cnf 在mysqld中加入下行 max_allowed_packet = 32M # service mysqld restart |
創建數據庫表
/etc/puppet-dashboard/config 必須在此目錄下:
# rake RAILS_ENV=production db:migrate |
* 報錯信息如下:
Gem::SourceIndex#add_spec called from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91. rake aborted! no such file to load -- rdoc/task /etc/puppet-dashboard/Rakefile:9 (See full trace by running task with --trace) |
解決方法:
# gem install rdoc |
安裝完成後,再次創建數據庫表,執行rake命令
* 報錯信息:
Gem::SourceIndex#add_spec called from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91. rake aborted! Could not find rack (~> 1.1.0) amongst [json-1.8.1, mysql-2.9.1, rdoc-4.0.1] (See full trace by running task with --trace) |
上述報錯信息,是由於rake版本導致,解決方法如下:
# gem install rack --version=1.1.2 |
再次創建數據庫表,已經可以順利完成。
測試dashboard正常工作
# cd .. # script/server -e production #通過瀏覽器進行訪問 |
訪問到dashboard頁面說明已經安裝完成。
三、配置Puppet dashboard
1.配置puppet向dashboard提交數據
Agent操作:
# vi /etc/puppet/puppet.conf [agent] report = true |
Master 操作:
# vi /etc/puppet/puppet.conf reports = store,http reporturl = http://localhost:3000/reports/upload #配置ENC node_terminus = exec external_nodes = /usr/bin/env PUPPET_DASHBOARD_URL=http://localhost:3000 /etc/puppet-dashboard/bin/external_node # service puppetmaster restart #重啓服務 |
監控
# env RAILS_ENV=production script/delayed_job -p dashboard -n 1 -m start |
運行任務
rake RAILS_ENV=production jobs:work |
重新打開瀏覽器,就可以看到reports