标签:cobbler
测试使用cobbler服务
一、基础环境 1、在tvm-base-centos66的基础上,复制一个镜像为tvm-cobbler来测试。 2、网络: eth0:host-only(用于虚拟内网,手动固定IP,这样从宿主机可以直接连接到这个vm) eth1:NAT(用于上外网,动态IP) [root@tvm-cobbler ~]# cd /etc/sysconfig/network-scripts/ [root@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 [root@tvm-cobbler network-scripts]# cat ifcfg-eth1 DEVICE=eth1 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=dhcp 二、配置cobbler环境 1、安装 因为局域网的yum源还没有同步epel的源,目前用公网的epel源: [root@tvm-cobbler ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm [root@tvm-cobbler ~]# yum makecache [root@tvm-cobbler ~]# yum -y install cobbler cobbler-web httpd dhcp rsync tftp-server pykickstart xinetd syslinux cman 2、配置 安装后: [root@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 先生成一个密码串: [root@tvm-cobbler ~]# openssl passwd -1 -salt ‘tvm-cobbler‘ Password: (TestVM) $1$tvm-cobb$RD9M3INq6sjYzh5Vrbf4S/ 更新http的密码: [root@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) [root@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 调整配置: [root@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 [root@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; [root@tvm-cobbler ~]# sed -i ‘s/yes/no/‘ /etc/xinetd.d/rsync [root@tvm-cobbler ~]# service xinetd restart 先check一下,然后按照提示检查配置。 [root@tvm-cobbler ~]# cobbler check [root@tvm-cobbler ~]# service cobblerd restart [root@tvm-cobbler ~]# cobbler sync 开机启动: chkconfig httpd on 3、导入os镜像 [root@tvm-cobbler ~]# mount -o loop /dev/scd0 /mnt [root@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 *** [root@tvm-cobbler ~]# umount /mnt/ [root@tvm-cobbler ~]# cd /var/lib/cobbler/kickstarts/ 4、调整profiles配置。 [root@tvm-cobbler kickstarts]# cp -a sample_end.ks CentOS-6.5-x86_64.ks 查看我修改了哪些配置: [root@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 > > [root@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一下来生效 [root@tvm-cobbler kickstarts]# cobbler sync *** TASK COMPLETE *** 上述文字结尾表示正常。 验证 [root@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 *** 也可以这样: [root@tvm-cobbler kickstarts]# curl http://192.168.56.252/cblr/svc/op/ks/profile/CentOS-6.5-x86_64 (略) # End final steps %end 上述文字结尾表示正常。 可以这样查看已经更改后的profiles的状态: [root@tvm-cobbler kickstarts]# cobbler profile report --name CentOS-6.5-x86_64 [root@tvm-cobbler kickstarts]# cat /var/lib/cobbler/config/profiles.d/CentOS-6.5-x86_64.json |python -m simplejson.tool 5、调整systems配置 针对指定的客户端来指定系统配置。 咱们来试着针对指定的mac地址做一个system方面的个性化配置: [root@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 [root@tvm-cobbler kickstarts]# cobbler system list cobbler-test [root@tvm-cobbler kickstarts]# cobbler system report --name=cobbler-test [root@tvm-cobbler kickstarts]# cobbler sync 二、在virtualbox上新建一个虚拟机来测试。 1、调整网卡,使用host-only,且去掉dhcp服务器的功能。 2、启动测试的虚拟机tvm-client1,按F12,按L键,进入pxe启动模式 三、FAQ Q:客户端从PXE启动后,弹出蓝色菜单要选择,意味着ks没有起作用,故障在哪里? A:检查以下内容: ------------------------------------------------------------- 试着浏览器或者curl访问下述URL: [root@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. 此时可以查看日志: [root@tvm-cobbler kickstarts]# tail /var/log/cobbler/cobbler.log ------------------------------------------------------------- ZYXW、参考 1、CENTOS6.5安装和配置COBBLER 2.4 http://blog.hackroad.com/operations-engineer/linux_server/11353.html
标签:cobbler
原文地址:http://nosmoking.blog.51cto.com/3263888/1675739