Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。

Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack


实验环境

centos6.8_x64


实验软件

epel-release-6-8.noarch.rpm

debmirror-20090807-1.el5.noarch.rpm

Django14-1.4.14-1.el6.noarch.rpm 


软件安装

rpm -ivh epel-release-6-8.noarch.rpm

yum localinstall -y  debmirror-20090807-1.el5.noarch.rpm

yum localinstall -y  Django14-1.4.14-1.el6.noarch.rpm 

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

yum install -y cman* pykickstart

yum install -y  ed  patch.x86_64   glibc.x86_64  perl.x86_64    perl-Compress-Zlib  perl-Cwd   

yum install -y   perl-Digest-SHA1  perl-LockFile-Simple perl-libwww-perl

cp -pv /etc/sysconfig/selinux  /etc/sysconfig/selinux.bak

echo >  /etc/sysconfig/selinux

echo SELINUX=disabled  >>  /etc/sysconfig/selinux    

service iptables stop 

chkconfig --level 35 iptables off


cobbler check     检测cobbler运行的问题
The following are potential configuration items that you may want to fix:

1 : The 'server' field in/etc/cobbler/settings must be set to something other than localhost, orkickstarting features will not work. This should be a resolvable hostname or IP for the boot server asreachable by all machines that will use it.

2 : For PXE to be functional, the'next_server' field in /etc/cobbler/settings must be set to something otherthan 127.0.0.1, and should match the IP of the boot server on the PXE network.

3 : some network boot-loaders are missingfrom /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to downloadthem, or, if you only want to handle x86/x86_64 netbooting, you may ensure thatyou have installed a *recent* version of the syslinux package installed and canignore this message entirely.  Files inthis directory, should you want to support all architectures, should includepxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' commandis the easiest way to resolve these requirements.

4 : change 'disable' to 'no' in/etc/xinetd.d/rsync

5 : since iptables may be running, ensure69, 80/443, and 25151 are unblocked

6 : debmirror package is not installed, itwill be required to manage debian deployments and repositories

7 : ksvalidator was not found, installpykickstart

8 : The default password used by the sampletemplates for newly installed machines (default_password_crypted in/etc/cobbler/settings) is still set to 'cobbler' and should be changed, try:"openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'"to generate new one

9 : fencing tools were not found, and arerequired to use the (optional) power management features. install cman orfence-agents to use them

Restart cobblerd and then run 'cobblersync' to apply changes.


sed -i.bak "s/#LoadModule/LoadModule/g"  /etc/httpd/conf.d/wsgi.conf

sed -i.bak  "s/#ServerName www.example.com:80/ServerName *:80/g" /etc/httpd/conf/httpd.conf 

sed -i.bak  "s/yes/no/" /etc/xinetd.d/rsync

sed -i.bak  "s/yes/no/" /etc/xinetd.d/tftp


cp -pv  /etc/cobbler/settings /etc/cobbler/settings.bak

sed -i "s/server: 127.0.0.1/server: 192.168.1.128/g" /etc/cobbler/settings

sed -i "s/next_server: 127.0.0.1/next_server: 192.168.1.128/g" /etc/cobbler/settings   192.168.1.128为服务器ip

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                 1为开启 0为关闭


openssl passwd -1 -salt 'random-phrase-here' '123456'     123456位root密码

$1$random-p$mzxQ/Sx848sXgvfwJCoZM0                         生成密文秘钥

vim   /etc/cobbler/settings

default_password_crypted:"$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."     找到

default_password_crypted: "$1$random-p$mzxQ/Sx848sXgvfwJCoZM0"    改为实际openssl生成的密码


cp  -pv  /etc/cobbler/dhcp.template /etc/cobbler/dhcp.template.bak

subnet 192.168.1.0 netmask 255.255.255.0 {                              dhcp分配网段

option routers             192.168.1.1;                                             网关

option domain-name-servers 192.168.1.1;                                dns配置

option subnet-mask         255.255.255.0;                                  子网掩码

range dynamic-bootp        192.168.1.100 192.168.1.105;         dhcp分配网段

service dhcpd configtest

Syntax: OK                出现ok表明dhcp配置正确,(默认此配置为模板)dhcp配置准从个人情况


sed -i.bak  "s/@dists/#@dists/" /etc/debmirror.conf

sed -i.bak  "s/@arches=/#@arches=/" /etc/debmirror.conf


cobbler get-loaders

task started: 2014-04-15_140352_get_loaders

task started (id=Download BootloaderContent, time=Tue Apr 15 14:03:52 2014)

downloadinghttp://www.cobblerd.org/loaders/README to /var/lib/cobbler/loaders/README


cobbler sync

running: service dhcpd restart

received on stdout: Starting dhcpd: [  OK  ]


vim /usr/lib/python2.6/site-packages/cobbler/action_check.py

if not os.path.exists("/usr/lib/systemd") and os.path.exists("/etc/xinetd.d"):

if not os.path.exists("/usr/lib/systemd") and not os.path.exists("/etc/xinetd.d"):   红笔为修改选项,选项用于centos6环境解决此错误

        status.append(_("file /etc/xinetd.d/rsync does not exist"))   

 

cobbler check

No configuration problemsfound.  All systems go.  看到这个提示就是说明配置正确


mkdir -p /system/centos6.9

mount -o loop CentOS-6.9-x86_64-bin-DVD1.iso /system/centos6.9

cobbler import --path=/system/centos6.9/ --name=centos6.9


du -sh  /var/www/cobbler/ks_mirror/centos6.9/

3.8G     /var/www/cobbler/ks_mirror/centos6.9/

du -sh  /root/CentOS-6.9-x86_64-bin-DVD1.iso 

3.7G     /root/CentOS-6.9-x86_64-bin-DVD1.iso


service cobblerd restart

service httpd restart

service xinetd restart

chkconfig --level 35 cobblerd on

chkconfig --level 35 httpd on

chkconfig --level 35 xinetd on


netstat -tuplna | grep httpd

tcp        0      0 :::80                       :::*                        LISTEN      29163/httpd  


netstat -tuplna | grep xinetd

tcp        0      0 :::873                      :::*                        LISTEN      29195/xinetd        

udp        0      0 0.0.0.0:69                  0.0.0.0:*                               29195/xinetd 


netstat -tuplna | grep dhcp

udp        0      0 0.0.0.0:67                  0.0.0.0:*                               28363/dhcpd         


ps -ef  | grep cobblerd

root      29229      1  0 13:41 ?        00:00:00 /usr/bin/python2.6 -s /usr/bin/cobblerd --daemonize

root      29239  26425  0 13:43 pts/3    00:00:00 grep cobblerd


cobbler report

Kickstart                      :/var/lib/cobbler/kickstarts/sample.ks 


cobbler system add --name=centos6_test  --hostname=centos6_test  --mac=00:0C:29:E3:81:32 --interface=eth0 --ip-address=192.168.1.123 --subnet=255.255.255.0 --gateway=192.168.1.1 --static=1 --profile=Centos-5.9-x86_64    --kickstart=/var/lib/cobbler/kickstarts/webserver.ks

通过 命令行装机   ks文件可自定义,默认无须指定


cobbler_第1张图片


cobbler_第2张图片

也可使用图形化方法


cobbler_第3张图片


https://serverip/cobbler_web    默认cobbler/cobbler   

cobbler_第4张图片


ll /etc/cobbler/modules.conf      cobbler-web配置目录

htdigest -c /etc/cobbler/users.digest Cobbler admin    设置cobbler_web admin密码


cobbler_第5张图片