基于Cobbler实现多版本系统自动部署
前言:
运维自动化在企业生产环境中越来越重要,当需要批量部署上百台甚至上千台服务器时,如果不通过自动化完成,根本不可想象;此前已经介绍过通过pxe+kickstart实现了简单的自动化安装,但是只能实现单一操作系统(单一操作系统,单一版本)的批量安装,面对生产环境中服务器的多种不同要求,此方法还是不够灵活;而Cobbler便可满足这一需求。
简介:
Cobbler是一个免费开源系统安装部署软件,用于自动化网络安装操作系统;基于python开发,是对PXE的二次封装,提供了CLI和Web的管理形式,也提供了API接口,方便二次开发使用。它不仅可以安装物理机,同时也支持虚拟化、Guest OS的安装。另外,Cobbler还能结合Puppet等集中化管理软件,实现自动化管理。
Cobbler各组件关系:
实验过程:
安装Cobbler:
cobbler由epel源提供,故此需要事先配置指向epel的yum源;cobbler会把依赖的服务一并安装,如tftp-server、httpd;还需要安装dncp、rsync等
[root@node0 ~]# yum install cobbler pykickstart debmirror dhcp rsync cman fence-agents[root@node0 ~]# service httpd start[root@node0 ~]# chkconfig tftp on[root@node0 ~]# chkconfig rsync on
配置Cobbler:
[root@node0 ~]# vim /etc/cobbler/settingsserver: 192.168.1.4next_server: 192.168.1.4[root@node0 ~]# cobbler get-loaders[root@node0 ~]# vim /etc/debmirror.conf #@dists="sid";#@arches="i386";[root@node0 ~]# openssl passwd -1 -salt `openssl rand -hex 4`$1$ca6a7d72$KDte4ZK00OCLiK4PLE4tp0[root@node0 ~]# vim /etc/cobbler/settingsdefault_password_crypted: "$1$ca6a7d72$KDte4ZK00OCLiK4PLE4tp0"[root@node0 ~]# service cobblerd start[root@node0 ~]# chkconfig cobblerd on[root@node0 ~]# cobbler sync
配置DHCP:
[root@node0 ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf[root@node0 ~]# vim /etc/dhcp/dhcpd.confsubnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.1 192.168.1.100; option routers 192.168.1.1; next-server 192.168.1.4; filename "pxelinux.0"; }[root@node0 ~]# service dhcpd start[root@node0 ~]# chkconfig dhcpd on
添加distro:挂载镜像,添加到cobbler;
[root@node0 ~]# mount /mnt/hgfs/lin/CentOS-6.7-x86_64-bin-DVD1.iso /mnt/cdrom/[root@node0 ~]# cobbler import --name=CentOS-6.7-x86_64 --path=/mnt/cdrom/ --kickstart=/root/anaconda-ks.cfgtask started: 2016-03-08_203724_importtask started (id=Media import, time=Tue Mar 8 20:37:24 2016)Found a candidate signature: breed=redhat, version=rhel6Found a matching signature: breed=redhat, version=rhel6Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64:skipping import, as distro name already exists: CentOS-6.7-x86_64No distros imported, bailing out!!! TASK FAILED !!!
查看当前distro:
[root@node0 ~]# cobbler distro list CentOS-6.7-x86_64
测试安装: