Cobbler自动化批量部署系统(0)_安装配置

1、采用yum epel源安装 Cobbler 、dhcp、httpd等服务及相关依赖包

1
2
3
4
5
$ wget -c http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm 
$ rpm -ivh epel-release-6-8.noarch.rpm
$ yum clean all
$ yum makecache
$ yum install cobbler cobbler-web httpd rsync tftp-server xinetd dhcp python-ctypes debmirror pykickstart

2、修改cobbler配置文件 /etc/cobbler/settings

1
2
3
4
5
6
7
8
9
10
11
12
#DHCP服务器地址 
next_server: 192.168.186.128
#cobbler服务器地址
server: 192.168.186.128
#将DHCP设置为cobbler管理
manage_dhcp: 1
#将rsync设置为cobbler管理
manage_rsync: 1
#将tftpd设置为cobbler管理
manage_tftpd: 1
#更该端口号(也可以使用默认的80号端口),更改端口号后,httpd配置文件的端口号也得更改为相同的
http_port: 8090

3、修改装机的默认密码(该密码 password 是新装机器root用户的登录密码)

1
2
3
4
$ openssl passwd -1 -salt 'random-phrase' 'password' 
$1$random-p$sFftrCTxKKsDZ.Sdr8mDG0
将生产的密码替换settings配置文件里的默认密码
default_password_crypted: "$1$random-p$sFftrCTxKKsDZ.Sdr8mDG0"

4、修改tftp和rsync服务配置文件开启tftp和rsync服务,将disable由“yes”改成“no”

1
2
3
4
5
6
7
8
9
10
11
$ cat /etc/xinetd.d/tftp 
service tftp
{
disable = no
...........................

$ cat /etc/xinetd.d/rsync
service rsync
{
disable = no
............................

5、修改cobbler提供的DHCP模板/etc/cobbler/dhcp.template,并替换dhcp的配置文件/etc/dhcp/dhcpd.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
subnet 192.168.186.0 netmask 255.255.255.0 { #修改为自己需求的网段 
option routers 192.168.186.2; #该网段的router地址,网关
option domain-name-servers 192.168.1.12; #DNS服务器地址
option subnet-mask 255.255.255.0; #掩码
range dynamic-bootp 192.168.186.100 192.168.186.254; #允许分配的IP段
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
}
}

6、修改httpd配置

1
2
3
4
5
6
7
8
9
10
11
12
13
httpd.conf监听端口修改与settings相同端口 
Listen 8090
#修改认证文件/etc/cobbler/modules.conf(最新的Cobbler版本貌似不用修改)
[authentication]
module = authn_configfile
[authorization]
module = authz_allowall
[dns]
module = manage_bind
[dhcp]
module = manage_isc
[tftpd]
module = manage_in_tftpd

修改/etc/httpd/conf.d/ssl.conf的ssl配置(增加以下行,如果不是用Cobbler提供的WEB端也可以不用配)

1
2
3
4
5
<VirtualHost *:8090> 
<LocationMatch "^/cobbler_web/*">
RewriteEngine on RewriteRule ^(.*) https://%{SERVER_NAME}/%{REQUEST_URI} [R,L]
</LocationMatch>
</VirtualHost>

修改cobbler的WEB页面管理密码WEB管理地址https://ip/cobbler_web 用户名cobbler 密码Cobbler

1
$ htdigest /etc/cobbler/users.digest "Cobbler" cobbler

7、校验cobbler安装条件并启动相关服务 需要启动的服务有httpdDHCPxinetdcobbler,需要关闭SELinuxIPtables。其它的报错按cobbler check提示解决

1
2
3
4
5
6
7
8
$ cobbler get-loaders 
$ cobbler check //如果检查有报错,请根据提示把报错都解决
No configuration problems found. All systems go.
$ cobbler sync
$ chkconfig --level 35 httpd on
$ chkconfig --level 35 xinetd on
$ chkconfig --level 35 dhcpd on
$ chkconfig --level 35 cobblerd on

8、导入系统镜像(先挂载后导入)

1
2
3
4
5
$ mount /dev/cdrom /media/ 
$ cobbler import --path=/media/ --name=CentOS64 --arch=x86_64
查看导入结果
$ cobbler distro list 完成后同步所有配置(同步数据到dhcp/pxe和数据目录)
$ cobbler sync

9、安装配置完成,新装机器开启pxe启动,重装机器设置第一引导项为pxe启动即可完成自动安装。
cobbler

----------------本文结束 感谢阅读----------------