Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CentOS6用に調整中のkickstart関連ファイル
#TODO
# package周り調整
# ディスク部分を外出しできるように。CentOS6で%ksappendがうまく動かなくて全部ベタ書きになってる
install
text
url --url=http://192.168.1.10/mrepo/centos6-x86_64/disc1/
lang ja_JP.UTF-8
keyboard jp106
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw --iscrypted XXXXXXXXXXXXXXXXXXXXXX
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone Asia/Tokyo
reboot
zerombr
bootloader --location=mbr --driveorder=vda --append="console=ttyS0,115200n8"
clearpart --all --initlabel --drives=vda
part /boot --fstype ext4 --size=100 --ondisk=vda
part swap --size=1024
part / --fstype ext4 --size=1 --grow
%packages
@base
@client-mgmt-tools
@console-internet
@core
@debugging
@development
@directory-client
@hardware-monitoring
@japanese-support
@java-platform
@large-systems
@network-file-system-client
@performance
@perl-runtime
@server-platform
@server-policy
pax
oddjob
sgpio
certmonger
pam_krb5
krb5-workstation
perl-DBD-SQLite
%pre
#/bin/sh
/usr/bin/wget http://192.168.1.10/setup/os_setup_centos6.sh -O /tmp/os_setup_centos6.sh
%post
%include /tmp/os_setup_centos6.sh
#%ksappend http://192.168.1.10/setup/os_setup_centos6.sh
<?php
//IPを固定に変えてるだけです
// 昔のvirt-installで引数に&を入れられないバグがあったので、クエリストリングをスペース区切りに
// ただXenのVMインストールする時にスペース区切りだとうまくいかなかったことが・・・
list($cfg, $hostname, $ip) = explode(" ", $_GET["cfg"]);
$ks_config = file_get_contents($cfg);
echo preg_replace(
"/^network.*/m",
"network --device eth0 --bootproto static "
. "--ip $ip --netmask 255.255.255.0 --gateway 192.168.1.1 "
. "--nameserver 192.168.1.103 "
. "--hostname $hostname",
$ks_config
);
#!/bin/sh
### useradd
useradd -u 1000 mikeda
sed -i 's|^mikeda:.*$|mikeda:XXXXXXXXXXXXX:15627:0:99999:7:::|' /etc/shadow
### add ssh keys
#mkdir /home/mikeda/.ssh
#chmod 700 /home/mikeda/.ssh
#chown mikeda.mikeda /home/mikeda/.ssh
#curl http://192.168.1.10/setup/authorized_keys > /home/mikeda/.ssh/authorized_keys
#chmod 600 /home/mikeda/.ssh/authorized_keys
#chwon mikeda.mikeda /home/mikeda/.ssh/authorized_keys
### hosts
#cat <<END >>/etc/hosts
#192.168.1.10 puppet-m.mikeda.jp
#END
### add repository
#rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
#curl http://192.168.1.10/setup/local.repo > /etc/yum.repos.d/local.repo
### resolv.conf
cat <<END >/etc/resolv.conf
nameserver 192.168.1.103
nameserver 192.168.1.1
search mikeda.jp
END
### sshd
sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
echo "sshd:192.168.1.0/255.255.255.0,127.,LOCAL" >> /etc/hosts.allow
echo "sshd:ALL" >> /etc/hosts.deny
### SUDO
sed -i '/^Defaults *requiretty/s/^/#/' /etc/sudoers
echo 'mikeda ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
### stop iptables
chkconfig ip6tables off
chkconfig iptables off
### stop service
chkconfig atd off
chkconfig auditd off
chkconfig autofs off
chkconfig cups off
chkconfig smartd off
### disable IPV6
cat <<END >> /etc/modprobe.d/ipv6.conf
options ipv6 disable=1
END
echo 'NETWORKING_IPV6=no' >> /etc/sysconfig/network
### stop SELinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
### ntp setting
/usr/sbin/ntpdate 210.173.160.27
#!/bin/bash
# TODO
# 複数NICのホストもできたので接続ブリッジとksdeviceの指定をもうちょっと厳密にする
# manのos-variantにvirtio26がなくなってるので調整したほうがいいのかな?
HOSTNAME=$1
IP=$2
LOCATION="http://192.168.1.10/mrepo/centos6-x86_64/disc1/"
TYPE=centos6_kvm
VCPUS=1
RAM=1024
DISK=10
IMG=/data/vm/${HOSTNAME}.img
if [ ! -f $IMG ];then
dd if=/dev/zero of=$IMG bs=1MiB count=`expr $DISK \* 1024`
else
echo already exists
exit
fi
virt-install --connect qemu:///system \
--name $HOSTNAME \
--ram $RAM \
--vcpus=$VCPUS \
--disk path=$IMG \
--os-type=linux \
--os-variant=virtio26 \
--accelerate \
--nographics \
--location="${LOCATION}" \
--extra-args="ks=http://192.168.1.10/ks/ks.php?cfg=${TYPE}.cfg+${HOSTNAME}+${IP} console=tty0 console=ttyS0,115200n8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment