Glide Note

glidenote's blog

Cobblerサーバの構築メモ

Cobblerを使って、業務で日常的にOSのインストールを しているんですが、Cobblerサーバ自体はチーム内の他の人が構築してくれてて、 自分で一から立てたことが無く、今回構築してみたのでメモ。

構築環境

  • CentOS release 5.8 (Final)
  • cobbler-2.0.11-2.el5
  • CobblerサーバのIP 172.17.8.11
  • PXEブートするIPレンジ 172.17.8.0/24

epelの導入

Cobblerはepelにあるので、epelをリポジトリに追加

1
2
3
4
mkdir ~/src
cd ~/src
wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -ivh epel-release-5-4.noarch.rpm

Cobblerの導入とサービスの起動

Cobblerと一緒に必要なパッケージが入るんですが、 dhcpは一緒に入らなかったのでdhcpも導入。

1
yum -y install cobbler dhcp

サービスを起動して、自動で起動するようにも設定

1
2
3
4
5
6
7
8
9
service cobblerd start
service httpd start
service xinetd start
service dhcpd start

chkconfig cobblerd on
chkconfig httpd on
chkconfig xinetd on
chkconfig dhcpd on

Cobblerの各種設定を用意

Cobblerを起動したらcobbler checkで設定ファイルをチェック。問題がある部分が表示されるので一個ずつ修正していきます。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
cobbler check

The following are potential configuration items that you may want to fix:

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
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/tftp
5 : change 'disable' to 'no' in /etc/xinetd.d/rsync
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
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/cobbler/settings

/etc/xinetd.d/tftp

/etc/xinetd.d/rsync

/etc/cobbler/dhcp.template

cobblerにdhcpdも管理させるのでdhcp.templateも修正

/etc/hosts.allow

hosts.allowにPXEブートするIPレンジを記載

1
2
3
bootps:         172.17.8.0/255.255.255.0
tftp:           172.17.8.0/255.255.255.0
in.tftpd:       172.17.8.0/255.255.255.0

bootloaderの用意

1
cobbler get-loaders

インストール用のディストリビューションを用意

cobbler importでCentOS5.8とScicentifc Linux6.2をimport。だいたい1つに30分〜40分かかります

1
2
3
cobbler import --path=rsync://ftp.jaist.ac.jp/pub/Linux/CentOS/5.8/os/x86_64/ --name=CentOS5.8-x86_64
cobbler import --path=rsync://ftp.jaist.ac.jp/pub/Linux/scientific/6.2/x86_64/os/ --name=SL6.2-x86_64
cobbler sync

再度設定をチェック

cobbler checkで再度設定をチェック。下記の注意書きが出ますが、関係ないので無視

1
2
3
4
5
6
7
The following are potential configuration items that you may want to fix:

1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
2 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
3 : 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.

各種設定が出来たので、Cobbler再起動して設定を反映

1
service cobblerd restart

動作確認

動作チェックのため、iptablesを一時的に止める

1
service iptables stop

適当なksファイル/var/lib/cobbler/kickstarts/mysql-server.ksなどを用意して、profileに登録

1
2
cobbler profile add --name=mysql-server --distro=CentOS5.8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/mysql-server.ks
cobbler sync

まっさらなサーバを起動してCobblerの画面が出るか確認

用意したmysql-serverを選択してインストール作業の確認

うまくいきました。

/etc/cobbler/settingsを眺めてたらgitやらpuppetやらの設定項目があって、 もっと便利に使えそうな予感が。

Comments