标签:cobbler
Cobbler自动化部署系统
Cobbler(补鞋匠)集成了PXE、DHCP、DNS、Kickstart服务管理和yum仓库管理工具,相对之前的 Kickstart 更加快捷、方便的批量布署Red Hat、CentOS类系统
一、关闭防火墙和selinux
略……
二、安装epel源
Yum install epel-release
三、安装相应的软件
yum -y install cobbler httpd rsynctftp-server xinetd dhcp pykickstart fence-agents
四、基础服务配置
Tftp配置
[root@localhost ~]# vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no ## 原为 yes
per_source = 11
cps = 100 2
flags = IPv4
}
Rsync配置
[root@localhost ~]# vim /etc/xinetd.d/rsync
service rsync
{
disable = no ## 原为 yes
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
http配置
[root@localhost ~]# vim /etc/httpd/conf
ServerName 127.0.0.1:80
Dhcp配置
[root@localhost ~]# vim/etc/cobbler/dhcp.template #直接配置该文件即可
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.100 192.168.1.120;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
五、cobbler配置
配置新安装系统的root密码
[root@localhost ~]# openssl passwd -1 -salt ‘test‘ ‘123456‘
$1$test$at615QShYKduQlx5z9Zm7/
test:加密root密码123456
123456:为新安装系统的root密码
“$1$test$at615QShYKduQlx5z9Zm7/”:表示生成的随机密码
[root@localhost ~]# vim/etc/cobbler/settings
manage_dhcp: 1 ## 原为 0 #cobbler自动管理dhcpd
manage_tftpd: 1 #cobbler自动管理tftpd
manage_rsync: 1 ## 原为 0 #cobbler自动管理dhcpd
next_server: 192.168.214.10 ## 本机 IP
server: 192.168.214.10 ## 本机 IP
default_password_crypted: "$1$test$at615QShYKduQlx5z9Zm7/" #生成新安装系统的root 密码
六、启动所有相关服务
[root@localhost ~]# chkconfig --add httpd
[root@localhost ~]# chkconfig --add xinetd
[root@localhost ~]# chkconfig --add dhcpd
[root@localhost ~]# chkconfig --addcobblerd
[root@localhost ~]# service httpd start
[root@localhost ~]# service xinetdstart
[root@localhost ~]# service dhcpd start
[root@localhost ~]# service cobblerd start
七、cobbler测试
[root@bogon yum.repos.d]# cobbler check
The following are potential configurationitems that you may want to fix:
1 : since iptables may be running, ensure69, 80/443, and 25151 are unblocked
2 : debmirror package is not installed, itwill be required to manage debian deployments and repositories
Restart cobblerd and then run ‘cobblersync‘ to apply changes.
注意:提示debmirror 没有安装,如果不是安装 debian 之类的系统,可以忽略此提示
错误信息:
[root@localhost ~]# cobbler check ## 检查配置
Traceback (most recent call last):
File "/usr/bin/cobbler", line 36, in <module>
sys.exit(app.main())
File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line655, in main
rc = cli.run(sys.argv)
File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line270, in run
self.token = self.remote.login("", self.shared_secret)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in__call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in__request
verbose=self.__verbose
File "/usr/lib64/python2.6/xmlrpclib.py", line 1253, inrequest
return self._parse_response(h.getfile(), sock)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1392, in_parse_response
return u.close()
File "/usr/lib64/python2.6/xmlrpclib.py", line 838, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: ":‘loginfailed‘">
处理方法:cobbler get-loaders
八、同步数据
[root@localhost ~]#cobbler sync
出现“*** TASKCOMPLETE ***”表示数据同步成功,然后重新启动xinetd和cobblerd服务
[root@localhost ~]# service xinetdrestart
[root@localhost ~]# service cobblerdrestart
九、导入linux系统
[root@localhost ~]# mount /dev/cdrom /mnt/
[root@localhost ~]# cobbler import--path=/mnt/ --arch=x86 --name=Centos-6.6-minimal
出现“*** TASKCOMPLETE ***”表示执行成功。
注意:Cobbler 将镜像拷贝一份放在/var/www/cobbler/ks_mirror/Centos-6.6-minimal-i386 目录下 )( 同时会创建一个名为 Centos-6.6-minimal-i386 的发布版本及 profile 文件 )
接下来执行重启、数据同步、查询执行结果
[root@localhost ~]# service cobblerdrestart
[root@localhost~]#cobbler sync
[root@bogonconfig]# cobbler distro list
Centos-6.5-minimal-i386
十、测试
在保障各项服务,已经成功启动的前提下,如果远程主机通过网络方式启动,就可以成功的安装操作系统。那么它是如果完成自动安装的呢?此时就需要kickstart来提供服务。
默认情况下,cobbler提供了一些kickstart的模板,既如何设置linux系统(如果分区,加载那些服务,关闭那些服务等等)。起默认的目录为/var/lib/cobbler/kickstarts/。如下所示,表示一些kickstart模块
[root@bogonkickstarts]# ll
total 56
-rw-r--r--. 1root root 115 Jun 12 14:07 default.ks
-rw-r--r--. 1root root 22 Jun 12 14:07 esxi4-ks.cfg
-rw-r--r--. 1root root 22 Jun 12 14:07 esxi5-ks.cfg
drwxr-xr-x. 2root root 4096 Aug 15 00:16 install_profiles
-rw-r--r--. 1root root 1424 Jun 12 14:07 legacy.ks
-rw-r--r--. 1root root 292 Jun 12 14:07 pxerescue.ks
-rw-r--r--. 1root root 2916 Jun 12 14:07 sample_autoyast.xml
-rw-r--r--. 1root root 1825 Jun 12 14:07 sample_end.ks
-rw-r--r--. 1root root 0 Jun 12 14:07sample_esx4.ks
-rw-r--r--. 1root root 324 Jun 12 14:07sample_esxi4.ks
-rw-r--r--. 1root root 386 Jun 12 14:07sample_esxi5.ks
-rw-r--r--. 1root root 1784 Jun 12 14:07 sample.ks
-rw-r--r--. 1root root 3419 Jun 12 14:07 sample_old.seed
-rw-r--r--. 1root root 5879 Jun 12 14:07 sample.seed
那么默认情况下,系统加载的那个kickstart模板呢?通过如下命令查看
[root@bogonkickstarts]#cobbler profile report --name Centos-6.5-minimal-i386
Name : Centos-6.5-minimal-i386
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-6.5-minimal-i386
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
#调用的模本为sample_end.ks
如何修改该kickstart模板呢?,通过如下命令
[root@localhost~]#
Cobblerprofile add --name=Centos-6.6-minimal --distro=Centos-6.6-minimal-i386 --kickstart=/var/lib/cobbler/kickstarts/Centos-6.6_minimal-i386.ks
kickstart模板如果制作呢?
安装system-config-kickstart
Yum installsystem-config-kickstart
2、如下所示,通过图形化界面配置ks引导文件
3、查看图形化配置后的信息
[root@localhost~]# cat new.cfg
#platform=x86,AMD64, or Intel EM64T
#version=DEVEL
# Firewallconfiguration
firewall--disabled
# Install OSinstead of upgrade
install
# Use networkinstallation
url --url="http://192.168.1.119/cobbler/ks_mirror/Centos-6.5-minimal-i386"
# Root password
rootpw--iscrypted $1$lQIechHf$Hxui3wElceUv4aPQap0o2.
# Systemauthorization information
auth --useshadow --passalgo=sha512
# Use graphicalinstall
graphical
firstboot--disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinuxconfiguration
selinux--disabled
# Installationlogging level
logging--level=info
# System timezone
timezone Asia/Shanghai
# Networkinformation
network --bootproto=dhcp--device=eth0 --onboot=on
# Systembootloader configuration
bootloader --location=mbr
# Clear theMaster Boot Record
zerombr
# Partitionclearing information
clearpart --all
# Diskpartitioning information
part /boot --asprimary --fstype="ext4" --size=200
part swap --fstype="swap" --size=2000
part /home --fstype="ext4" --size=5000
part / --fstype="ext4" --grow --size=1
十一、测试新ks是否成功
1、更改KS,配置文件为new.ks
[root@localhost~]#
Cobblerprofile add --name=test --distro=Centos-6.6-minimal-i386 --kickstart=/var/lib/cobbler/kickstarts/new.ks
说明:为“Centos-6.6-minimal-i386”镜像文件,添加test的profile,其使用的kickstart为new.ks
可以通过如下命令查看,现在的test的信息
[root@localhost~]# Cobbler profile report--name=test
2、同步配置
[root@localhost~]#cobbler sync
3、看是否能够远程安装系统(选择 test)
标签:cobbler
原文地址:http://469952080.blog.51cto.com/8311493/1687494