cobbler介绍
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。
Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。
cobbler安装准备
关闭iptables与selinux
chkconfig iptables off |
安装源准备并安装cobbler软件yum -y install debmirror
yum -y install httpd rsync tftp-server xinetd dhcp python-ctypes pykickstart fence-agents
rpm -ivh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum -y install cobbler
wget http://ftp.linux.ncsu.edu/pub/epel/6/x86_64/Django14-1.4.21-1.el6.noarch.rpm
yum -y install cobbler-web
配置tftp-server与rsync
开启tftp与rsync服务
chkconfig tftp on |
配置httpd配置文件vim /etc/httpd/conf/httpd.conf
sed -i "/#ServerName/a\ServerName $ip:80" /etc/httpd/conf/httpd.conf
配置cobbler主配置文件
sed -i "s/next_server: 127.0.0.1/next_server: $ip/g" /etc/cobbler/settings |
配置cobbler web登录认证配置文件
grep -B 1 "module = authn_configfile" /etc/cobbler/modules.conf --color |
设置Cobbler用户名密码
htdigest /etc/cobbler/users.digest "Cobbler" cobbler |
备注:”Cobbler”务必大写,否则帐号虽然创建,会无法登录
生成Cobbler安装系统root初始密码
openssl passwd -1 -salt 'random-phrase-here' 'root' $1$random-p$WbZ3JxhRzCS/1Ne4S9g4Z. |
将上面的加密串加入cobbler配置文件中

配置DHCPmv /etc/cobbler/dhcp.template /etc/cobbler/dhcp.template.bak
vim /etc/cobbler/dhcp.template
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.1;
option domain-name-servers 192.168.10.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.10.200 192.168.10.220;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
启动相关服务chkconfig httpd on
chkconfig xinetd on
chkconfig dhcpd on
chkconfig cobblerd on
service httpd restart
service xinetd restart
service dhcpd restart
service cobblerd restart
检查配置,执行cobbler check
执行完后出现下面的信息
The following are potential configuration items that you may want to fix:
The following are potential configuration items that you may want to fix:
1 : service dhcpd is not running
2 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
3 : file /etc/xinetd.d/rsync does not exist
4 : comment out 'dists' on /etc/debmirror.conf for proper debian support
5 : comment out 'arches' on /etc/debmirror.conf for proper debian support
- 暂时先忽略,因为/etc/dhcp/dhcpd.conf 文件没有配置,通过cobbler去同步配置
- 执行 cobbler get-loaders,系统将自动下载loader程序,完成提示2的修复工作。
- 忽略(感觉是系统误报)
- 修复debian/Ubuntu系统安装选项支持包
- 修复debian/Ubuntu系统安装选项支持包
vim /etc/debmirror.conf |
说明:前提是安装debmirror pykickstart这两个包!

所有提示全部修复之后,执行cobbler check
执行同步 cobbler sync
再次检查配置
重启所有服务service cobblerd restart
service xinetd restart
service httpd restart
service dhcpd restart
导入linux ISO安装镜像
挂载ISO光盘镜像mount /dev/sr0 /mnt
开始导入光盘镜像cobbler import --path=/mnt/ --arch=x86_64 --name CentOS6.7
ks装机模版
#platform=x86, AMD64, or Intel EM64T |
批量新增装机信息
对文本app.txt格式做如下约定
| sn | ks-profile | hostname | mac | ip |
|---|---|---|---|---|
| 6QZKXD2 | CentOS6.7-x86_64 | test.com | 28:F1:0E:58:53:6E | 10.40.100.101 |
#/usr/bin/env python |