no about note

エンジニアのメモ書き

CentOS6にCobblerをインストールする

http://cobbler.github.io/images/logo-brand.png

Cobblerとは

Cobblerインストール

Cobbler Quickstart Guide

事前準備

# cat /etc/redhat-release
CentOS release 6.7 (Final)

## iptables停止
# service iptables status
iptables: ファイアウォールが稼働していません。

# service ip6tables status
ip6tables: ファイアウォールは稼働していません。

## SELinux停止
# sestatus
SELinux status:                 disabled

## yum update しておく
# yum update

SELinuxを使いたい場合はここを参照

パッケージのインストール

## epelリポジトリのインストール
# yum install epel-release

## cobbler-webとxinetdも同時にインストール
# yum install cobbler cobbler-web xinetd

# rpm -qa | grep cobbler
cobbler-2.6.11-1.el6.x86_64
cobbler-web-2.6.11-1.el6.noarch

Cobblerの設定

rootのパスワード生成

  • KickstartインストールしたOSにデフォルトで設定されうrootパスワードを生成する
  • /etc/cobbler/settingsで設定する
# openssl passwd -1
Password:
Verifying - Password:
$1$HeqpEd76$FzWrkZWRRrmVD2pblgM1n0

/etc/cobbler/settings

// cobblerd再起動せずに設定を反映する
#allow_dynamic_settings: 0
↓
allow_dynamic_settings: 1

// インストールするOSのrootパスワード (生成したパスワードを入力)
#default_password_crypted: "$1$lum3B52i$wS/8vYIAAXowm7bIhEpuu/"
↓
default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."

// Cobbleがdhcpサービスを管理することを許可する
#manage_dhcp: 0
↓
manage_dhcp: 1

// Cobbleがrsyncサービスを管理することを許可する
#manage_rsync: 0
↓
manage_rsync: 1

// Cobblerサーバが待ちうけるIPアドレス
#server: 127.0.0.1
↓
server: (Cobblerサーバ自身IPアドレス)

// DHCP/PXEサーバが待ちうけるIPアドレス
#next_server: 127.0.0.1
↓
next_server: (Cobblerサーバ自身IPアドレス)

DHCPサーバのインストールと設定

DHCPサーバのインストール

# yum install dhcp

# rpm -qa | grep dhcp
dhcp-4.1.1-49.P1.el6.centos.x86_64
dhcp-common-4.1.1-49.P1.el6.centos.x86_64

/etc/cobbler/dhcp.templateの設定

  • /etc/dhcp/dhcp.confではないので注意
subnet 172.16.0.0 netmask 255.255.0.0 {
     option routers             172.16.0.1;   // デフォルトゲートウェイを指定
     option domain-name-servers 172.16.0.1;   // ネームサーバを指定(あれば)
     option subnet-mask         255.255.0.0;   //ネットマスク
     range dynamic-bootp        172.16.200.1 172.16.200.253;  // DHCPのIPレンジを指定

dhcpd起動と自動起動の設定

# chkconfig dhcpd on
# service dhcpd start

Cobblerの起動と自動起動の設定

# chkconfig cobblerd on

# service cobblerd start
Starting cobbler daemon:                                   [  OK  ]

Apache(Cobbler_Web用)自動起動設定

# chkconfig httpd on

# service httpd start

Cobbler Check

  • 設定に問題がないかチェックする
  • これで出たエラーとかを解決していく感じ
# cobbler check
The following are potential configuration items that you may want to fix:

1 : service dhcpd is not running
2 : change 'disable' to 'no' in /etc/xinetd.d/tftp
3 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
4 : change 'disable' to 'no' in /etc/xinetd.d/rsync
5 : file /etc/xinetd.d/rsync does not exist
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : ksvalidator was not found, install pykickstart
8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.

/etc/xinetd.d/tftp 設定

  • disable を yes -> noに
# cat /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        disable                 = no  
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -B 1380 -v -s /var/lib/tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

/etc/xinetd.d/rsync 設定

  • disable を yes -> noに
# cat /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#       allows crc checksumming etc.
service rsync
{
        disable         = no
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}

xinetd再起動

# service xinetd restart

cobblerd再起動

# service cobblerd restart
Stopping cobbler daemon:                                   [  OK  ]
Starting cobbler daemon:                                   [  OK  ]

Cobber_web

  • CobblerのWebインターフェース
  • デフォルトではユーザ/パスワードは、cobbler/cobbler

http://localhost/cobber_web

get-loaders

# cobbler get-loaders
task started: 2016-03-23_171220_get_loaders
task started (id=Download Bootloader Content, time=Wed Mar 23 17:12:20 2016)
downloading http://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading http://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***

OSイメージの取り込み

OSイメージをダウンロード

# cd /mnt
# wget http://www.ftp.ne.jp/Linux/packages/CentOS/7/isos/x86_64/CentOS-7-x86_64-Everything-1511.iso

# mount CentOS-7-x86_64-Everything-1511.iso /mnt

cobbler import

# cobbler import --name CentOS-7-x86_64-Everything --path /mnt

task started: 2016-03-08_164454_import
task started (id=Media import, time=Tue Mar  8 16:44:54 2016)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-7-x86_64-Everything:
creating new distro: CentOS-7-Everything-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7-x86_64-Everything -> /var/www/cobbler/links/CentOS-7-Everything-x86_64
creating new profile: CentOS-7-Everything-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS-7-x86_64-Everything for CentOS-7-Everything-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7-x86_64-Everything
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7-x86_64-Everything
looking for /var/www/cobbler/ks_mirror/CentOS-7-x86_64-Everything/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7-x86_64-Everything/repodata
*** TASK COMPLETE ***

# cobbler distro list
   CentOS-7-Everything-x86_64

# cobbler distro report --name=CentOS-7-Everything-x86_64

# umount /mnt/

パッケージリポジトリミラーリング

OSパッケージ用のリポジトリをCobblerに取り込む

# cobbler repo add --name CentOS-7-x86_64-updates --mirror http://ftp.iij.ad.jp/pub/linux/centos/7/updates/x86_64/
# cobbler repo add --name CentOS-7-x86_64-extras --mirror http://ftp.iij.ad.jp/pub/linux/centos/7/extras/x86_64/
# cobbler repo add --name epel7 --mirror http://ftp.iij.ad.jp/pub/linux/fedora/epel/7/x86_64
# cobbler repo list
  CentOS-7-x86_64-extras
  CentOS-7-x86_64-updates
  epel7

reposyncをCronに登録

# echo "48 2 * * * cobbler reposync --tries 2 --no-fail" >> /var/spool/cron/root

pxe_just_onceを有効にする

# cobbler setting report --name pxe_just_once
pxe_just_once                           : 0
# cobbler setting edit --name pxe_just_once --value 1

もう一度PXEブートしたい場合

# cobbler system edit --name xxxx --netboot-enabled True

Distribution、Profile、Systemsについて

  • Distributionは、OSのディストリビューションごと(CentOS6、CentOS7とか)
  • Profileは、WebサーバとかDBサーバとかざっくりした用途ごとらしい
  • Systemsはサーバ固有の設定(Macアドレスなどで指定する)

Cobbler Profiles作成

##  cobbler profile add --name=(Profileの名前) --distro=(Distributionの名前) --kickstart=(Kickstartファイル名)

# cobbler profile add --name=mysql-server --distro=CentOS-7-Everything-x86_64 --kickstart=/var/lib/cobbler/kickstarts/mysql-server.ks

# cobbler profile list
# cobbler profile report --name=mysql-server

# cobbler sync

Cobbler Systems追加

## Cobbler system add
# cobbler system add  \
--name hogehoge \          # system名を指定(addの場合はこの名前でsystemが作成される)
--hostname=hogehoge \   # Hostnameを設定
--profile=mysql-server \                   # 利用するprofileを指定
--interface=eth0 \                             # 設定するインターフェースを指定
--mac=xx:xx:xx:xx:xx:xx \             # eth0のMACアドレス
--static=1 \                                        # 固定IP or DHCP (DHCPの場合は0)
--ip=xxx.xxx.xxx.xxx \                     # eth0のIPアドレス
--subnet=255.255.255.0 \                 # eth0のサブネットマスク
--gateway=xxx.xxx.xxx.xxx \          # eth0のゲートウェイ
--name-servers=8.8.8.8 \                 # 参照するDNSサーバ
--kopts='ksdevice=eth1'                  # カーネルオプションがある場合はここで指定

## Cobbler edit
# cobbler system edit \
--name=hogehoge \          # system名を指定(editの場合は、この名前のsystemを変更)
--interface=eth1 \                             # 設定するインターフェースを指定
--mac=xx:xx:xx:xx:xx:xx \             # eth1側のMACアドレス
--static=1 \                                        # 固定IP or DHCP (DHCPの場合は0)
--ip=xxx.xxx.xxx.xxx \                     # eth1のIPアドレス
--subnet=255.255.255.0                    # eth1のサブネットマスク

# cobbler system list

## Cobbler Report
# cobbler system report --name=hogehoge

## edit Kickstart file
# cobbler system edit --name=hogehoge --kickstart=/var/lib/cobbler/kickstarts/hogehoge.ks

# cobbler sync

Cobblerのコマンドリファレンス

## Help
# cobbler --help
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ...
        [add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]

参考