一、安装配置Dshboard1、功能说明Puppet Dasshboard是由支持Puppet开发的公司Puppetlabs创建的,是Ruby on Rails程序;可以作为一个ENC(外部节点分类器)以及一个报告工具,包含许多Puppet新功能的集成界面,例如审计和资源管理功能;
能显示Puppet master和agent的相关信息;它能作为一个ENC来配置Puppet节点,并指定这些节点上的类和参数;Puppet Dashboard(1.2.3)程序目前版本只支持Ruby 1.8.x,以及只支持MySQL作为数据库后端。
官方配置指南:https://docs.puppetlabs.com/dashboard/manual/1.2/2、安装软件包安装rubygem-rake12[root@puppet ~]# rpm -ivh ftp://rpmfind.net/linux/centos/6.5/os/x86_64/Packages/rubygem-rake-0.8.7-2.1.el6.noarch.rpm
[root@puppet ~]# yum install -y ruby-mysql mysql-server puppet-dashboard3、配置mysql123456789101112[root@puppet ~]# service mysqld start
[root@puppet ~]# chkconfig mysqld on[root@puppet ~]# mysqladmin -uroot password 123456[root@puppet ~]# mysql -p123456
mysql> create database dashboard character set utf8;mysql> grant all on dashboard.* to dashboard@localhost identified by “123456”;
mysql> flush privileges;mysql> quit[root@puppet ~]# vi /etc/my.cnf[mysqld]max_allowed_packet=32M[root@puppet ~]# service mysqld restart
4、配置dashboard123456789101112[root@puppet ~]# cd /usr/share/puppet-dashboard/[root@puppet puppet-dashboard]# vi config/database.yml
production: database: dashboard username: dashboard password: 123456 encoding: utf8 adapter: mysql
[root@puppet puppet-dashboard]# vi config/settings.ymltime_zone: Asia/Shanghai[root@puppet puppet-dashboard]# rake gems:refresh_specs
[root@puppet puppet-dashboard]# rake RAILS_ENV=production db:migrate使用合适的表填充数据库,环境变量RAILS_ENV=production告诉Ruby on Rails我们工作在生产环境。
1[root@puppet puppet-dashboard]# service puppet-dashboard start5、检查数据查看导入数据:1234567891011121314151617
18192021222324252627[root@puppet ~]# mysql -udashboard -p123456mysql> use dashboard;mysql> show tables;
+——————————+| Tables_in_dashboard |+——————————+| delayed_job_failures |
| delayed_jobs || metrics || node_class_memberships || node_classes |
| node_group_class_memberships || node_group_edges || node_group_memberships || node_groups |
| nodes || old_reports || parameters || report_logs |
| reports || resource_events || resource_statuses || schema_migrations |
| timeline_events |+——————————+18 rows in set (0.00 sec)mysql> quit查看工作状态:
123456789101112[root@puppet ~]# cd /usr/share/puppet-dashboard/[root@puppet puppet-dashboard]# ./script/server -e production
=> Booting WEBrick=> Rails 2.3.17 application starting on http://0.0.0.0:3000=> Call with -d to detach
=> Ctrl-C to shutdown server[2014-11-14 15:36:28] INFO WEBrick 1.3.1[2014-11-14 15:36:28] INFO ruby 1.8.7 (2011-06-30) [x86_64-linux]
[2014-11-14 15:36:28] INFO WEBrick::HTTPServer#start: pid=36461 port=3000^C[2014-11-14 15:37:36] INFO going to shutdown …
[2014-11-14 15:37:36] INFO WEBrick::HTTPServer#start done.Exiting可以看到dashboard默认运行在WEBrick的3000端口,按Ctrl+C关闭服务,下面改成apache运行。
二、dashboard整合apache1、配置参考示例:/usr/share/puppet-dashboard/ext/passenger/dashboard-vhost.conf12345678910
11121314[root@puppet ~]# vi /etc/httpd/conf.d/dashboard.confListen 8141 DocumentRoot /usr/share/puppet-dashboard/public
Options None AllowOverride AuthConfig
Order allow,deny allow from all ErrorLog /var/log/httpd/dashboard.error.log
LogLevel warn CustomLog /var/log/httpd/dashboard.access.log combined不是在配置passenger.conf上面修改,而是新建的专门给dashboard的配置,端口也不一样。
2、服务关闭WEBRick使用apache代替12345[root@puppet ~]# service puppet-dashboard stop[root@puppet ~]# service puppetmaster stop
[root@puppet ~]# service httpd restart[root@puppet ~]# iptables -I INPUT -p tcp –dport 8141 -j ACCEPT
[root@puppet ~]# service iptables save3、检查不能显示页面:http://10.188.1.73:3000/可以正常显示页面:http://10.188.1.73:8141/
1[root@puppet ~]# tailf /var/log/httpd/dashboard.access.log
1[root@puppet ~]# puppet agent –server puppet.ewin.com –test
三、Puppet整合Dashboard1、手动导入12345[root@puppet ~]# cd /usr/share/puppet-dashboard/[root@puppet puppet-dashboard]# rake RAILS_ENV=production reports:import
Importing 13456 reports from /var/lib/puppet/reports in the backgroundImporting: 100% |#########################################| Time: 00:06:27
13456 of 13456 reports queuedpuppet报告保存目录/var/lib/puppet/reports/页面左上角“Backgroud Tasks”表示正在等待的任务(将puppet传给http的reports导入dashboard),但没有生效,使用如下命令启动修改:
1[root@puppet puppet-dashboard]# env RAILS_ENV=production script/delayed_job -p dashboard -n 1 -m start
2、自动导入(整合)(1)Linux客户端配置:123[root@zabbix ~]# vi /etc/puppet/puppet.conf[agent]report = true #从2.7.0版本开始默认开启
(2)Windows客户端配置:12D:\Program Files\Puppet Labs\Puppet\puppet\ext\redhat\puppet.confC:\ProgramData\PuppetLabs\puppet\etc\puppet.conf
两个配置文件都没有设置report=true但报告正常,待解~~(3)Puppet服务端配置(关键):1234[root@puppet ~]# vi /etc/puppet/puppet.conf[main]
reports = http,store #如果不加上store,将不再在/var/lib/puppet/reports/存储报告reporturl = http://localhost:8141/reports
如果要取消puppet集成dashboard,注消上面两行即可如果是在puppet服务端直接修改,别忘了提交到SVN,因此建议养成在管理机器上修改的习惯:1[root@puppet ~]# svn ci /etc/puppet/ -m “update reports url”。
(4)启动服务:12345678[root@puppet ~]# service httpd restart[root@puppet ~]# cd /usr/share/puppet-dashboard/
[root@puppet puppet-dashboard]# rake RAILS_ENV=production jobs:work[Worker(host:puppet.ewin.com pid:61845)] Starting job worker
[Worker(host:puppet.ewin.com pid:61845)] Report.create_from_yaml_file completed after 2.2778[Worker(host:puppet.ewin.com pid:61845)] Report.create_from_yaml_file completed after 1.0872
[Worker(host:puppet.ewin.com pid:61845)] Report.create_from_yaml_file completed after 1.0863[Worker(host:puppet.ewin.com pid:61845)] Report.create_from_yaml_file completed after 2.2699 …
Rake命令使导入报告任务开始运行,运行后可以按Ctrl+C退出,它会在后台自动运行;1[root@puppet puppet-dashboard]# echo “rake RAILS_ENV=production jobs:work” >> /etc/rc.local
Rake命令需要加入到开机启动,否则你会发现重启服务器后Dashboard的WEB页面的最新reports不更新了,而且左上角的“Backgroud Tasks”等待任务在不断增加,就是因为这个开机后没运行导致的。
3、其他命令优化数据库:1[root@puppet puppet-dashboard]# rake RAILS_ENV=production db:raw:optimize删除报告:123[root@puppet puppet-dashboard]# rake RAILS_ENV=production reports:prune upto=1 unit=mon
Deleting reports before 2014-10-15 08:38 UTC…Deleted 0 reports.upto=1 unit=mon表示1个月前的报告,可用day表示天1 查看报告:
红色表示运行失败橙色表示等待运行蓝色表示运行成功及改变的信息绿色表示运行成功但什么都没做