天天看點

foreman的安裝配置方法

介紹

foreman是一個puppet的生命周期管理系統,類似puppet-dashboard,通過它可以很直覺的檢視puppet所有用戶端的同步狀态與facter參數,目前隻有Ohad Levy, Frank Sweetser, Paul Kelly三位在默默無聞的管理開發這個項目,更多資料請參見foreman官方站:http://theforeman.org

官方截圖:http://theforeman.org/projects/foreman/wiki/Screenshots

本文介紹下foreman安裝步驟,供各位研究puppet的朋友參考之用。

系統環境:CentOS5.4

yum源: CD光牒iso、dag-rpmforge、fedora-epel (mirrors.sohu.com)

puppet版本:puppet-0.25.4.rpm

前提準備

安裝rake

yum install rubygem-rake rubygem-rack-1.0.1-1 rubygem-sqlite3-ruby

下載下傳foreman最新tar包

cd /opt

http://theforeman.org/p_w_uploads/download/104/foreman-0.1-5.tar.bz2

tar -jxf foreman-0.1-5.tar.bz2

也可以通過git下載下傳

git clone git://github.com/ohadlevy/foreman.git foreman

cd foreman

git submodule init

git submodule update

複制foreman-report腳本

cp extras/puppet/foreman/files/foreman-report.rb /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb

添加foreman使用者

useradd foreman -d /opt/foreman -M -s /sbin/nologin

安裝foreman

cd /opt/foreman

rake Rakefile && rake

# foreman預設使用sqlite資料庫,不需要改動資料庫配置,如果你更喜歡MySQL的話,請手動建立foreman、foremandevel、foremantest三個庫,然後修改資料庫配置檔案 foreman/config/database.yml 為以下内容。

production:

    adapter: mysql

    database: foreman

    username: root

    password:

    host: localhost

    socket: "/var/lib/mysql/mysql.sock"

development:

    database: foremandevel

test:

    database: foremantest

建立資料庫表結構

RAILS_ENV=production rake db:migrate

導入節點與facter資訊

# This will import your facts (only new facts) every time you run the script.

rake puppet:import:hosts_and_facts RAILS_ENV=production

# This will create all required settings from your facts.

rake puppet:migrate:populate_hosts RAILS_ENV=production

建立服務檔案 /etc/sysconfig/foreman

# the location where foreman is installed

#FOREMAN_HOME=/usr/share/foreman

# the port which foreman web server is running at

# note that if the foreman user is not root, it has to be a > 1024

#FOREMAN_PORT=3000

# the user which runs the web interface

#FOREMAN_USER=foreman

# the rails environment in which foreman runs

#FOREMAN_ENV=production

建立服務啟動腳本 /etc/init.d/foreman

#!/bin/bash

#

# Init script for foreman

# chkconfig: - 85 15

# description: Init script for foreman

# Source function library.

. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/foreman ]; then

        . /etc/sysconfig/foreman

fi

prog=foreman

RETVAL=0

# open port 80 need root user

FOREMAN_PORT=${FOREMAN_PORT:-3000}

FOREMAN_USER=${FOREMAN_USER:-root}

FOREMAN_HOME=${FOREMAN_HOME:-/opt/foreman}

FOREMAN_ENV=${FOREMAN_ENV:-production}

FOREMAN_PID=${FOREMAN_PID:-${FOREMAN_HOME}/tmp/pids/server.pid}

start() {

        echo -n $"Starting $prog: "

     daemon --user ${FOREMAN_USER} /usr/bin/ruby ${FOREMAN_HOME}/script/server -p ${FOREMAN_PORT} -e ${FOREMAN_ENV} -d > /dev/null

#    daemon /usr/bin/ruby ${FOREMAN_HOME}/script/server -p 80 -e ${FOREMAN_ENV} -d >/dev/null

        RETVAL=$?

        if [ $RETVAL = 0 ]

        then

                echo_success

        else

                echo_failure

        fi

        echo

        return $RETVAL

}

stop() {

        echo -n $"Stopping $prog: "

        if [ -f ${FOREMAN_PID} ]; then

                killproc -p ${FOREMAN_PID}

                RETVAL=$?

                echo -n $"Foreman was not running.";

                failure $"Foreman was not running.";

                echo

                return 1

# See how we were called.

case "$1" in

        start)

                start

        ;;

        stop)

                stop

        status)

                echo -n "Foreman"

                status -p $FOREMAN_PID

        restart)

        *)

                echo $"Usage: $prog {start|stop|restart}"

                exit 1

esac

exit $RETVAL

chmod 755 /etc/init.d/foreman

修改puppetmaster的puppet.conf

reports=log, foreman

配置郵件報警 config/email.yaml

# Outgoing email settings

# config/email.yaml

    delivery_method: :smtp

    smtp_settings:

        address: mail.example.com

        port: 25

        domain: example.com

        authentication: :none

修改基本配置 config/settings.yaml

:modulepath: /etc/puppet/modules/

:tftppath: tftp/

:rrd_report_url: report/

#:ldap: true

#your default puppet server - can be overridden in the host level

#if none specified, plain "puppet" will be used.

:puppet_server: puppet

:unattended: false

#use the following setting to override the default 30 minutes puppet run interval - value must be in minutes

:puppet_interval: 10

:document_root: /var/www

#:puppetrun: true

:administrator: [email protected]

:failed_report_email_notification: true

啟動服務

service foreman start

使用firefox、chrome浏覽http://localhost:3000

繼續閱讀