Cobbler有人称之为装系统神奇,当你用了之后你会发现确实如此哈,下记录一下使用过程:

一、安装

我系统环境是centos6.4,采用yum安装:

yum -y install cobbler  cobbler-web  httpd rsync tftp-server xinetd dhcp python-ctypes debmirror pykickstart

二、配置

1、关闭防火墙和SELinux 后重启系统: 

/etc/init.d/iptables stop         #关闭防火墙
chkconfig iptables off
sed -i '/SELINUX=/d' /etc/selinux/config &&  echo "SELINUX=disabled">> /etc/selinux/config  #关闭SELINUX

2、修改cobbler配置文件:

 

'next_server: 127.0.0.1' 替换成 'next_server:172.28.26.188'    #DHCP服务地址
'server: 127.0.0.1' 替换成 'server: 172.28.26.188'   #cobbler服务地址
'manage_dhcp: 0' 替换成 'manage_dhcp: 1'      #cobbler管理dhcp
'manage_rsync: 0' 替换成 'manage_rsync: 1'     #cobbler管理rsync功能
'http_port: 80'替换成 'http_port: 9080'     #更改端口号9080
default_password_crypted: "$1$1111$vZEjq1D9/uNasiTXwyx4o."  #修改这个默认密码,因为运行cobbler check时会提示你修改密码, 用这个命令实现"openssl passwd -1 -salt '任意字母' '你的密码' "
sed -i 's/next_server: 127.0.0.1/next_server: 172.28.26.188/g' /etc/cobbler/settings
sed -i 's/server: 127.0.0.1/server: 172.28.26.188/g' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
sed -i 's/manage_rsync: 0/manage_rsync: 1/g' /etc/cobbler/settings
sed -i 's/http_port: 80/http_port: 9080/g' /etc/cobbler/settings
openssl passwd -1 -salt '1234312' 'navy123456'    #把生成的密码填到/etc/cobbler/settings配置里default_password_crypted:生成的新密码

3、修改tftp服务和rsync服务配置 :

sed -i '/disable/c disable = no' /etc/xinetd.d/tftp    #设置 'disable' 为 'no'
sed -i -e 's/= yes/= no/g' /etc/xinetd.d/rsync        #设置 'disable' 为 'no'

4、修改dhcp模板 :

vim /etc/cobbler/dhcp.template
subnet 172.28.26.0 netmask 255.255.255.0 {     #修改为自己需求网段
option routers             172.28.26.188;                 #修改自己的路由
option domain-name-servers 172.28.26.188;    #域名服务器地址
option subnet-mask         255.255.255.0;         #子网掩码
range dynamic-bootp        172.28.26.191 172.28.26.193;    #分配IP地址段
filename                   "/pxelinux.0";
default-lease-time         21600;
max-lease-time             43200;
next-server                $next_server;
}

5、修改cobbler-web配置 :

sed -i 's/Listen 80/Listen 9080/g' /etc/httpd/conf/httpd.conf  #修改hhtp端口为9080
sed -i 's/module = authn_denyall/module = authn_configfile/g' /etc/cobbler/modules.conf   #修改认证
htdigest  /etc/cobbler/users.digest "Cobbler" cobbler  #修改cobbler WEB页面管理密码
vim  /etc/httpd/conf.d/ssl.conf     #修改ssl配置,把下面几行添加到配置后面即可


RewriteEngine on
RewriteRule ^(.*) https://%{SERVER_NAME}/%{REQUEST_URI} [R,L]

6、启动相关的服务:

/etc/init.d/httpd start
/etc/init.d/xinetd start
/etc/init.d/dhcpd start
/etc/init.d/cobblerd start
chkconfig --level 35 httpd on
chkconfig --level 35 xinetd on
chkconfig --level 35 dhcpd on
chkconfig --level 35 cobblerd on

7、效验cobbler安装条件:

service cobblerd restart
cobbler get-loaders       #修复cobbler check时出现的错误信息
cobbler check

三、导入镜配置:

挂载ISO镜像到/mnt目录
mount -o loop /data/kisops_centos6.3._vm.iso /mnt/
导入ISO,并设置为“x86_64”,并将其命名为Centos6.3。(注:具体可查看/var/www/cobbler/ks_mirror/Centos6.4-x86_64/目录文件生成情况。)
cobbler import --path=/mnt/   --name=Centos6.3  --arch=x86_64
查看导入结果
cobbler distro list
完成后同步所有配置
cobbler sync

四、需要抓系统的机器从网卡启动就可以了

Cobbler体验小记_第1张图片

PS:附加一下ks.cfg

#set $swap= $getVar('$swap', '12000')
autostep --autoscreenshot
install
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
text
skipx
lang en_US.UTF-8
keyboard us
network --onboot yes --bootproto dhcp --noipv6 --nodns
rootpw  --iscrypted \$6\$Qz7FvhTWfC2yTdb1\$qNF1o.fpE44l/F1ROzJ.bXRKeB4OVQ.maYCY3tMZKDS7tDLrHthIAREXZFvW1G08tOqptkLMxfvyW4wA.vPOz1
firewall --disabled
firstboot --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
#timezone --isUtc Asia/Shanghai
timezone --utc Asia/Shanghai
# 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
logging --level=info
#bootloader --append="nohz=off" --location=mbr
bootloader --location=mbr --driveorder=sda --append="biosdevname=0 nohz=off thash_entries=1048576 rhash_entries=1048576 selinux=0"
zerombr yes
# clearpart --all --initlabel --drives=sda
clearpart --all --initlabel
# ignoredisk --only-use=sda
part / --fstype=ext4 --asprimary --size=50000 --maxsize=50000 --label=/
part swap --asprimary --size=$swap --maxsize=$swap --label=swap
part /data --fstype=xfs --grow --asprimary --size=12000 --label=/data
%pre
$SNIPPET('pre_install_network_config')
# Add Pre-Installation Script here
date
%end
%packages --excludedocs --ignoremissing
@base
@core
@development
@server-policy
ftp
nc
telnet
cmake
compat-gcc-34
compat-gcc-34-c++
sgpio
libXtst
yum-plugin-priorities
koan
openssl
tengine
-lvm2
-acpid
-biosdevname
-hunspell-en
-abrt-cli
-man-pages-overrides
-blktrace
-words
-abrt-addon-kerneloops
-abrt-addon-ccpp
-bridge-utils
-nano
-mtr
-hunspell
-abrt-addon-python
-man-pages
-byacc
-indent
-diffstat
-doxygen
-intltool
-git
-ctags
-cscope
-iptables
-system-config-firewall-base
-iptables-ipv6
-system-config-firewall-tui
-subversion
%end
$SNIPPET('services_disable_enable')
%post
$SNIPPET('post_install_network_config')
$SNIPPET('env_init')
$SNIPPET('kis_cobbler_api')
$SNIPPET('cactirelease')
$SNIPPET('kisyum_install')
/usr/sbin/eject -rv /dev/sr* # eject P cdrom
echo 'v1.3' > ~root/VERSION
%end
# finish
reboot --eject