Xiaopei's DokuWiki

These are the good times in your life,
so put on a smile and it'll be alright

User Tools

Site Tools


it:puppet:dashboard

puppet dashboard

Puppet Dashboard can be used as an External Node Classifier (ENC) as well as a reporting tool, and is moving towards being an integration interface for a variety of new Puppet functions including audit and inventory capabilities

tips

bootstrapping

Dashboard Manual: Installing — Documentation — Puppet Labs

In outline, the steps to get Dashboard running are:

  1. Installing the external dependencies
  2. Installing the Dashboard code
  3. Configuring Dashboard
  4. Creating and configuring a MySQL database
  5. Testing that Dashboard is working
  6. Configuring Puppet
  7. Starting the delayed job worker processes
  8. Running Dashboard in a production-quality server

安装依赖需要注意 rubygems 不能直接用 apt 安装

apt-get install -y build-essential irb libmysql-ruby libmysqlclient-dev \
   libopenssl-ruby libreadline-ruby mysql-server rake rdoc ri ruby ruby-dev
 
# Install the RubyGems package system, using the following shell script — 
# do not use the rubygems packaged with the operating system:
$ (
   URL="http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz"
   PACKAGE=$(echo $URL | sed "s/\.[^\.]*$//; s/^.*\///")
 
   cd $(mktemp -d /tmp/install_rubygems.XXXXXXXXXX) && \
   wget -c -t10 -T20 -q $URL && \
   tar xfz $PACKAGE.tgz && \
   cd $PACKAGE && \
   sudo ruby setup.rb
 )
 
# Create gem as an alternative name for the gem1.8 command:
$ update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.8 1

apt 安装 puppet dashboard 可先安装一个puppetlabs-release来配置 apt, 再 apt-get install puppet-dashboard.

$ wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb; dpkg -i puppetlabs-release-precise.deb
$ apt-get update
$ apt-get install puppet-dashboard

安装后要初始化数据库:

  1. 根据 /etc/puppet-dashboard/database.yml 在 mysql 建数据库
  2. 初始化
    $ cd /usr/share/puppet-dashboard/
    $ rake db:migrate
     
    # 生成环境
    $ rake RAILS_ENV=production db:migrate

配置:

  1. on each agent
puppet.conf
[agent]
  report = true
  1. on puppet master
puppet.conf
[master]
  reports = store, http
  reporturl = http://dashboard.example.com:3000/reports/upload

service puppet-dashboard start后, puppet agent 连一下如果显示如下, 则配置正确:

之后再 service puppet-dashboard-workers start, nodes 就能在 dashboard 中显示了. 若 service 启动不了, 可 cd 到 puppet-dashboard 下使用

$ sudo -u puppet-dashboard env RAILS_ENV=production script/delayed_job -p dashboard -n 4 -m start

但 workers 启动不了的真正原因还是需要看 puppet-dashboard/log/delayed_job.log. 很可能是 mysql CHARACTER SET 不对!

settings.yml 的 time_zone 可设置时区

使用 passenger + apache

  1. 安装 passenger 和 apache
    apt-get install apache2 libapache2-mod-passenger rails librack-ruby libmysql-ruby
  2. cp puppet-dashboard/ext/passenger/dashboard-vhost.conf /etc/apache2/sites-enabled/
  3. 修改 dashboard-vhost.conf (dpkg 安装的 passenger 在 /etc/apache2/mods-enabled 中已有配置, 需注释掉 dashboard-vhost.conf 的内容)
  4. 对 apache 配置做相应修改, 如 ports.conf
  5. service apache restart

使用 passenger + nginx

  1. 安装 passenger 后, nginx 中 puppet dashboard 配置如下
    server {
    	server_name dashboard.puppet.com;
    	root /usr/share/puppet-dashboard/public;
    	passenger_enabled on;
    
    	# 允许本地直接访问, 以支持 puppet master 做 report
    	# puppet 自身有 bug 不支持 http 验证(http://projects.puppetlabs.com/issues/7173)
    	satisfy  any;
    	allow 127.0.0.0/8;
    	deny   all;
    
    	# 但其他 IP 访问需做验证
    	auth_basic            "puppet dashboard";
    	auth_basic_user_file  "/etc/puppet-dashboard/htpasswd";
    }
  2. 生成 http auth 密码
    $ htpasswd -bc htpasswd USER PASS

refs

inventory

Inventory Service — Documentation — Puppet Labs

You can use this API to get complete info about any node, and to search for nodes whose facts meet certain criteria

开启 inventory

  1. puppet master
    1. 增加 auth.conf
      path /facts
      auth yes
      method find, search
      allow dashboard
      # dashboard 为 cert 名
      # allow * 开放访问
  2. puppet dashboard
    1. 修改 settings.yml
      enable_inventory_service: true
      inventory_server: 'puppet_master'
      # 用实际 server 替换
    2. 另需注意 dashboard 运行时的用户 需与 /usr/share/puppet-dashboard/certs/dashboard.private_key.pem 相同

使用 puppetDB(as inventory service backends)

  1. 安装, 用 apt-get 就行, the hard way 或 troubleshooting 可参考: PuppetDB 1 » Installing PuppetDB — Documentation — Puppet Labs
    $ aptitude install puppetdb
  2. 启动, puppetdb 起不来? 看看端口是否被占用!
    $ service puppetdb start
  3. Connecting Puppet Masters to PuppetDB
    1. 安装 puppet-terminus
      $ apt-get install puppetdb-terminus
    2. 根据文档修改 puppet 配置, 需要注意 puppetDB 似乎在用 puppet 的 ca1), 所以 puppetdb.conf 的 server 要填与 ca 中一致的地址(不能用 localhost)!

puppetdb 不支持 mysql 做后端, 支持 postgreSQL:

It lacks several features we do or will depend on, including array columns and recursive queries. We’re committing to PostgreSQL as our preferred database for the future, as it strikes the right balance between the features of Oracle and the pricetag of.. well, free. 2)

高级问题

The Foreman

安装

1)
ca 机制不了解, 原因是不是这个尚不确定
it/puppet/dashboard.txt · Last modified: 2014/11/25 17:03 by admin