今までは各サーバごとに同じような内容のkickstartファイルを書いていたが、共通するようなセットアップファイルがたくさんできて大変気持ち悪かった。
それをどうにかするために、kickstartファイルから設定部分外だししてみた次第。
# myfinder's Kickstart file.
install
url --url http://{Local YUM Server}/centos/5/os/x86_64
lang ja_JP.UTF-8
keyboard jp106
network --device eth0 --bootproto static --ip {Local IP} --netmask {NETMASK} --gateway {GATEWAY} --nameserver {NAME SERVER} --hostname {HOSTNAME}
network --device eth1 --bootproto static --ip {GLOBAL IP} --netmask {NETMASK} --gateway {GATEWAY} --nameserver {NAME SERVER} --hostname {HOSTNAME}
rootpw --iscrypted {ENCRYPTED PASSWORD}
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --enforcing
timezone Asia/Tokyo
bootloader --location=mbr
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all
part /boot --fstype ext3 --size=100
part pv.2 --size=0 --growvolgroup VolGroup00 --pesize=32768 pv.2
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --growlogvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=512 --grow --maxsize=1024
reboot
%packages
@base
@core
@development-libs
@development-tools
@editors
keyutils
trousers
fipscheck
device-mapper-multipath
imake
ntp
%post
# post setting
wget -P /tmp http://{SVN Server}/svn/server-settings/trunk/kickstart/setup.sh
bash /tmp/setup.sh
rm -f /tmp/setup.sh
と、言う風にしておいて、setup.shを下記のように書いておく。
# server settings
# SELinux off
setenforce 0
# ntp setting
curl -o /etc/ntp.conf -O http://{SVN Server}/svn/server-settings/trunk/etc/ntp.confchmod 644 /etc/ntp.conf
chkconfig ntpd on
service ntpd start
# ldap setting
authconfig --enableldap --enableldapauth --ldapserver={LDAP Server} --ldapbasedn=dc=example,dc=jp --updateall
curl -o /etc/ldap.conf -O http://{SVN Server}/svn/server-settings/trunk/etc/ldap.conf
chmod 644 /etc/ldap.conf
curl -o /etc/pam.d/system-auth-ac -O http://{SVN Server}/svn/server-settings/trunk/etc/pam.d/system-auth-ac
chmod 644 /etc/pam.d/system-auth-ac
# root pw delete
perl -pi.bak -e "s/(root:)[^:].*?(:.*?)$/\1\!\!\2/" /etc/shadow
# ssh setting
yum remove -y openssh openssh-server openssh-clientsrpm -ivh http://{Local YUM Server}/rpms/i386/openssh-4.3p2-26.lpk.i686.rpm
rpm -ivh http://{Local YUM Server}/rpms/i386/openssh-clients-4.3p2-26.lpk.i686.rpm
rpm -ivh http://{Local YUM Server}/rpms/i386/openssh-server-4.3p2-26.lpk.i686.rpm
curl -o /etc/ssh/sshd_config -O http://{SVN Server}/svn/server-settings/trunk/etc/ssh/sshd_config
chmod 600 /etc/ssh/sshd_config
service sshd restart
# local yum repo setting
curl -o /etc/yum.repos.d/myfinder.repo -O http://{SVN Server}/svn/server-settings/trunk/etc/yum.repos.d/myfinder.repo
chmod 644 /etc/yum.repos.d/myfinder.repo
# iptables setting
curl -o /etc/sysconfig/iptables -O http://{SVN Server}/svn/server-settings/trunk/etc/sysconfig/iptables
chmod 600 /etc/sysconfig/iptables
service iptables restart
# system service setting
chkconfig ntpd on
chkconfig bluetooth off
chkconfig cups off
chkconfig firstboot off
chkconfig gpm off
chkconfig haldaemon off
chkconfig hidd off
chkconfig ip6tables off
chkconfig kudzu off
chkconfig pcscd off
chkconfig xfs off
chkconfig yum-updatesd off
# SELinux on
setenforce 1
# report mail
echo "$HOSTNAME setup completed" | mail -s "$HOSTNAME setup report" medianetworks@gmail.com
こうやっておけば、kickstartファイルや、その先のセットアップスクリプトもバージョン管理できるし、サーバ特有にすべき内容を分割できる。
あと、セットアップ後でもスクリプトを実行すれば新しい設定ファイルを適用できる。
