1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
| 一、基础环境
1、在tvm-base-centos66的基础上,复制一个镜像为tvm-cobbler来测试。
2、网络:
eth0:host-only(用于虚拟内网,手动固定IP,这样从宿主机可以直接连接到这个vm)
eth1:NAT(用于上外网,动态IP)
[iyunv@tvm-cobbler ~]# cd /etc/sysconfig/network-scripts/
[iyunv@tvm-cobbler network-scripts]# cat ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.56.252
PREFIX=24
GATEWAY=192.168.56.1
[iyunv@tvm-cobbler network-scripts]# cat ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
二、配置cobbler环境
1、安装
因为局域网的yum源还没有同步epel的源,目前用公网的epel源:
[iyunv@tvm-cobbler ~]# rpm -ivh http://dl.fedoraproject.org/pub/ ... ease-6-8.noarch.rpm
[iyunv@tvm-cobbler ~]# yum makecache
[iyunv@tvm-cobbler ~]# yum -y install cobbler cobbler-web httpd dhcp rsync tftp-server pykickstart xinetd syslinux cman
2、配置
安装后:
[iyunv@tvm-cobbler ~]# ls /etc/cobbler/
auth.conf dnsmasq.template named.template secondary.template zone.template
cheetah_macros import_rsync_whitelist power settings zone_templates
cobbler_bash iso pxe tftpd.template
completions ldap reporting users.conf
dhcp.template modules.conf rsync.exclude users.digest
distro_signatures.json mongodb.conf rsync.template version
先生成一个密码串:
[iyunv@tvm-cobbler ~]# openssl passwd -1 -salt 'tvm-cobbler'
Password: (TestVM)
$1$tvm-cobb$RD9M3INq6sjYzh5Vrbf4S/
更新http的密码:
[iyunv@tvm-cobbler ~]# htdigest /etc/cobbler/users.digest "relbboc" cobbler
Adding user cobbler in realm relbboc
New password: (relbboc)
Re-type new password:(relbboc)
也可以通过这种方式来测试:
# authn_testing -- username/password is always testing/testing (debug)
[iyunv@tvm-cobbler ~]# sed 's/ = authn_configfile/ = authn_testing/' /etc/cobbler/modules.conf
调整防火墙,允许:
tcp
80
443
25151
udp
69
sed -i -e 's|@dists=.*|#@dists=|' /etc/debmirror.conf
sed -i -e 's|@arches=.*|#@arches=|' /etc/debmirror.conf
调整配置:
[iyunv@tvm-cobbler ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$tvm-cobb$RD9M3INq6sjYzh5Vrbf4S/"
manage_dhcp: 1
manage_tftpd: 1
manage_rsync: 1
next_server: 192.168.56.252 # 接管DHCP服务器后,指定cobbler服务器的IP
server: 192.168.56.252 # cobbler服务器IP
[iyunv@tvm-cobbler ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.56.0 netmask 255.255.255.0 {
option routers 192.168.56.252;
option domain-name-servers 192.168.56.254;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.56.150 192.168.56.199;
[iyunv@tvm-cobbler ~]# sed -i 's/yes/no/' /etc/xinetd.d/rsync
[iyunv@tvm-cobbler ~]# service xinetd restart
先check一下,然后按照提示检查配置。
[iyunv@tvm-cobbler ~]# cobbler check
[iyunv@tvm-cobbler ~]# service cobblerd restart
[iyunv@tvm-cobbler ~]# cobbler sync
开机启动:
chkconfig httpd on
3、导入os镜像
[iyunv@tvm-cobbler ~]# mount -o loop /dev/scd0 /mnt
[iyunv@tvm-cobbler ~]# cobbler import --path=/mnt/ --name=CentOS-6.5-x86_64
task started: 2015-07-16_171121_import
task started (id=Media import, time=Thu Jul 16 17:11:21 2015)
(等待导入完成)
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.5-x86_64:
creating new distro: CentOS-6.5-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64 -> /var/www/cobbler/links/CentOS-6.5-x86_64
creating new profile: CentOS-6.5-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64 for CentOS-6.5-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6.5-x86_64/repodata
*** TASK COMPLETE ***
[iyunv@tvm-cobbler ~]# umount /mnt/
[iyunv@tvm-cobbler ~]# cd /var/lib/cobbler/kickstarts/
4、调整profiles配置。
[iyunv@tvm-cobbler kickstarts]# cp -a sample_end.ks CentOS-6.5-x86_64.ks
查看我修改了哪些配置:
[iyunv@tvm-cobbler kickstarts]# diff sample_end.ks CentOS-6.5-x86_64.ks
21c21
< lang en_US
---
> lang en_US.UTF-8
38c38
< timezone America/New_York
---
> timezone Asia/Shanghai
44c44,48
< autopart
---
> #autopart
> part /boot --bytes-per-inode=4096 --fstype="ext4" --size=200
> part swap --bytes-per-inode=4096 --fstype="swap" --size=4096
> part / --bytes-per-inode=4096 --fstype="ext4" --size=1 --grow
>
55a60,65
> @Base
> @Development Tools
> @Chinese-Support
> ntp
> lrzsz
> git
75a86,124
>
> ### repo ###
> #
> mv /etc/yum.repos.d/*.repo /tmp/ \
> && wget http://mirrors.office.test/local-office.repo -O /etc/yum.repos.d/local-office.repo \
> && yum makecache
>
> ### ssh config ###
> #
> mv /etc/ssh/sshd_config /etc/ssh/sshd_config.old \
> && cat > /etc/ssh/sshd_config << "_SSHD"
> \# added by cobbler
> Port 22
> Protocol 2
> SyslogFacility AUTHPRIV
> \#PasswordAuthentication no
> \#PermitRootLogin no
> ChallengeResponseAuthentication no
> GSSAPIAuthentication no
> GSSAPICleanupCredentials no
> UsePAM yes
> AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
> AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
> AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
> AcceptEnv XMODIFIERS
> X11Forwarding yes
> UseDNS no
> Subsystem sftp /usr/libexec/openssh/sftp-server
> _SSHD
>
> ### datetime ###
> #
> cat > /var/spool/cron/root << "_CRON"
> \# [daily]
> \# added by cobbler
> */20 * * * * /usr/sbin/ntpdate ntp.office.test >/dev/null 2>&1 &
> _CRON
>
>
[iyunv@tvm-cobbler kickstarts]# cobbler profile edit \
--name=CentOS-6.5-x86_64 \
--distro=CentOS-6.5-x86_64 \
--kickstart=/var/lib/cobbler/kickstarts/CentOS-6.5-x86_64.ks
修改配置后,记得要sync一下来生效
[iyunv@tvm-cobbler kickstarts]# cobbler sync
*** TASK COMPLETE ***
上述文字结尾表示正常。
验证
[iyunv@tvm-cobbler kickstarts]# cobbler validateks
task started: 2015-07-17_175218_validateks
task started (id=Kickstart Validation, time=Fri Jul 17 17:52:18 2015)
----------------------------
osversion: rhel6
checking url: http://192.168.56.252/cblr/svc/op/ks/profile/CentOS-6.5-x86_64
running: /usr/bin/ksvalidator -v "rhel6" "http://192.168.56.252/cblr/svc/op/ks/profile/CentOS-6.5-x86_64"
received on stdout:
received on stderr:
----------------------------
osversion: rhel6
checking url: http://192.168.56.252/cblr/svc/op/ks/system/cobbler-test
running: /usr/bin/ksvalidator -v "rhel6" "http://192.168.56.252/cblr/svc/op/ks/system/cobbler-test"
received on stdout:
received on stderr:
*** all kickstarts seem to be ok ***
*** TASK COMPLETE ***
也可以这样:
[iyunv@tvm-cobbler kickstarts]# curl http://192.168.56.252/cblr/svc/op/ks/profile/CentOS-6.5-x86_64
(略)
# End final steps
%end
上述文字结尾表示正常。
可以这样查看已经更改后的profiles的状态:
[iyunv@tvm-cobbler kickstarts]# cobbler profile report --name CentOS-6.5-x86_64
[iyunv@tvm-cobbler kickstarts]# cat /var/lib/cobbler/config/profiles.d/CentOS-6.5-x86_64.json |python -m simplejson.tool
5、调整systems配置
针对指定的客户端来指定系统配置。
咱们来试着针对指定的mac地址做一个system方面的个性化配置:
[iyunv@tvm-cobbler kickstarts]# cobbler system edit \
--name=cobbler-test \
--profile=CentOS-6.5-x86_64 \
--hostname=tvm-test \
--interface=eth0 \
--mac=08:00:27:BF:43:92 \
--ip-address=192.168.56.200 \
--subnet=255.255.255.0 \
--gateway=192.168.56.252 \
--static=1 \
--name-servers=192.168.56.254
[iyunv@tvm-cobbler kickstarts]# cobbler system list
cobbler-test
[iyunv@tvm-cobbler kickstarts]# cobbler system report --name=cobbler-test
[iyunv@tvm-cobbler kickstarts]# cobbler sync
二、在virtualbox上新建一个虚拟机来测试。
1、调整网卡,使用host-only,且去掉dhcp服务器的功能。
2、启动测试的虚拟机tvm-client1,按F12,按L键,进入pxe启动模式
三、FAQ
Q:客户端从PXE启动后,弹出蓝色菜单要选择,意味着ks没有起作用,故障在哪里?
A:检查以下内容:
-------------------------------------------------------------
试着浏览器或者curl访问下述URL:
[iyunv@tvm-cobbler kickstarts]# curl http://192.168.56.252/cblr/svc/op/ks/profile/CentOS-6.5-x86_64
如果有错误,则会提示:
# This kickstart had errors that prevented it from being rendered correctly.
# The cobbler.log should have information relating to this failure.
此时可以查看日志:
[iyunv@tvm-cobbler kickstarts]# tail /var/log/cobbler/cobbler.log
-------------------------------------------------------------
ZYXW、参考
1、CENTOS6.5安装和配置COBBLER 2.4
http://blog.hackroad.com/operati ... x_server/11353.html
|