Kickstartを調べてみた
Kickstart
Kickstartとは?
OSを自動インストールすための仕組み。 単一のサーバ上で管理されたKickstartファイルを、OSのインストールを行う各コンピュータ上で読み込み、その内容に従ってインストール時に手動で行っていた作業(パーティション設定やインストールパッケージの選択など)を自動でおこなう。
なお、Kickstartの実行結果は/tmp配下に出力されているので、失敗した時にはここを見る。
設定項目
以下を参照
サンプル
# システムに認証オプションを設定 # 以下はMD5でシャドウパスワードを使用(default) auth --useshadow --enablemd5 # ブートローダのインストール方法を指定 # 以下はMBRに書き込む bootloader --location=mbr # 新しいパーティションを作成する際に、システムからパーティションを削除 # 以下はすべてのパーティションを削除する # が、「--initlabel」オプションは現在廃止されているらしく、「zerombr」に置き換わった。 ★こっちはNG clearpart --all --initlabel ★こっちで zerombr clearpart --all # インストールをテキストモードで実行。指定しない場合、グラフィカルモードになる text # firewallを有効に firewall --enabled # fistbootは無効に。https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/ch-firstboot.html firstboot --disable # keybordタイプを指定。MacがUS配列なので、その通りに keyboard us # システム言語指定。英語で lang en_US # installオプションの指定 # ----------------------------------------------------------- # url指定の場合 ## http url --url=http://192.168.11.2/cblr/links/CentOS6.6-x86_64 ## ftp url --url=ftp://user:pass@host/dir # ローカル光学ドライブから cdrom # ローカルHDD harddrive --partition=hda1 --dir=/hoge/fuga # 指定したNFSサーバ nfs --server=nfsserver.hoge.com --dir=/hoge/fuga # パッケージインストール用のソースとして使用できるyumリポジトリ。複数行可 repo --name=source-1 --baseurl=http://192.168.11.2/cobbler/ks_mirror/CentOS6.6 # ネットワークの設定 # --bootprotoはdhcp / bootp(dhcpと同じ扱い) / ibft / staticのいずれか # eth0を起動時に有効にし、DHCPを使用する例 network --bootproto=dhcp --device=eth0 --onboot=on # eth1を起動時に有効にし、固定IPを指定 network --bootproto=static --deice=eth1 --onboot=on --ip=192.168.11.15 --netmask=255.255.255.0 --gateway=192.168.11.2 --nameserver=192.168.11.2,8.8.8.8 # インストール後リブート reboot # rootのパスワード。$ openssl passwd -1で生成した値を指定 rootpw --iscrypted $1$ihF.N2JP$CDbqwuyTLzJ9NiiKSdzaE1 # SELinuxを無効に selinux --disabled # Xは設定しない(GUIは使わない) skipx # タイムゾーン指定。 timezone Asia/Tokyo # アップグレードではなく新規インストール install # パーティションを自動作成 autopart # インストール処理前にroot権限で実行するコマンドを指定(〜%endまで) %pre # 標準出力、標準エラー出力を/tmp/ks-pre.logへリダイレクト set -x -v exec 1>/tmp/ks-pre.log 2>&1 # ログをコピー while : ; do sleep 10 if [ -d /mnt/sysimage/root ]; then cp /tmp/ks-pre.log /mnt/sysimage/root/ logger "Copied %pre section log to system" break fi done & # プロファイル情報を取得 wget "http://192.168.11.2/cblr/svc/op/trig/mode/pre/profile/CentOS6.6-x86_64" -O /dev/null %end # インストールするパッケージの指定 %packages puppet %end %post --nochroot set -x -v exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1 %end # インストール処理後にroot権限で実行する処理 %post # 標準出力、標準エラー出力を/tmp/ks-post.logへリダイレクト # なので、インストール完了後リブートしたクライアントマシン上で何か問題があれば、これらを見る set -x -v exec 1>/root/ks-post.log 2>&1 # yumのリポジトリ情報を取得して保存 wget "http://192.168.11.2/cblr/svc/op/yum/profile/CentOS6.6-x86_64" --output-document=/etc/yum.repos.d/cobbler-config.repo # Cobblerサーバの情報を書き込む echo "export COBBLER_SERVER=192.168.11.2" > /etc/profile.d/cobbler.sh echo "setenv COBBLER_SERVER 192.168.11.2" > /etc/profile.d/cobbler.csh # 処理に使用したKickstartの内容を保存 wget "http://192.168.11.2/cblr/svc/op/ks/profile/CentOS6.6-x86_64" -O /root/cobbler.ks wget "http://192.168.11.2/cblr/svc/op/trig/mode/post/profile/CentOS6.6-x86_64" -O /dev/null %end
使い方
Cobblerを使う
$ cobbler profile add --name=なまえ --profile=CentOS6.6 --kickstart=使いたいKickstartファイル
手動でpxelinux.cfgにかく
label 1 kernel RHEL6/vmlinuz append initrd=RHEL6/initrd.img ramdisk_size=10000 ks=使いたいKickstartファイル ``