基於Cobbler實現多版本系統自動部署

基於Cobbler實現多版本系統自動部署

前言:

  運維自動化在企業生產環境中愈來愈重要,當須要批量部署上百臺甚至上千臺服務器時,若是不經過自動化完成,根本不可想象;此前已經介紹過經過pxe+kickstart實現了簡單的自動化安裝,可是隻能實現單一操做系統(單一操做系統,單一版本)的批量安裝,面對生產環境中服務器的多種不一樣要求,此方法仍是不夠靈活;而Cobbler即可知足這一需求。node

簡介:

  Cobbler是一個免費開源系統安裝部署軟件,用於自動化網絡安裝操做系統;基於python開發,是對PXE的二次封裝,提供了CLI和Web的管理形式,也提供了API接口,方便二次開發使用。它不只能夠安裝物理機,同時也支持虛擬化、Guest OS的安裝。另外,Cobbler還能結合Puppet等集中化管理軟件,實現自動化管理。python

Cobbler各組件關係:linux

輸入圖片說明

實驗過程:

安裝Cobbler:vim

  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/settings
server: 192.168.1.4
next_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/settings
default_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.conf
subnet 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.cfg
task started: 2016-03-08_203724_import
task started (id=Media import, time=Tue Mar  8 20:37:24 2016)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64:
skipping import, as distro name already exists: CentOS-6.7-x86_64
No distros imported, bailing out
!!! TASK FAILED !!!

查看當前distro:操作系統

[root@node0 ~]# cobbler distro list
   CentOS-6.7-x86_64

測試安裝:code

輸入圖片說明 輸入圖片說明

相關文章
相關標籤/搜索