cobbler:
pxe的二次封装:python语言开发,可以为我们提供dhcp服务以及tftp服务;
可以实现多环境的pxe共存
pxe:dhcp,tftp
程序包:cobbler(epel)
服务:CentOS 7:systemctl start cobblerd.service
核心概念:distro,profile,system
cobbler:distro(repository)-->profile(kickstart)-->system(ip/mask)
测试环境:CentOS7
一、配置及启动cobbler所依赖的各服务
[root@localhost ~]# yum install -y cobbler [root@localhost ~]# rpm -ql cobbler | grep "\<settings\>" /etc/cobbler/settings #此为cobbler的主配置文件 /usr/lib/python2.7/site-packages/cobbler/settings.py /usr/lib/python2.7/site-packages/cobbler/settings.pyc /usr/lib/python2.7/site-packages/cobbler/settings.pyo [root@localhost ~]# systemctl start cobblerd #启动cobbler [root@localhost ~]# cobbler check #进行cobbler check,我们需要解决cobbler所报出的问题,其中第3、4、7问题可以暂时忽略。 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, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable 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 other than 127.0.0.1, and should match the IP of the boot server on the PXE network. 3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment: https://github.com/cobbler/cobbler/wiki/Selinux 4 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/tftp 5 : 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. 6 : file /etc/xinetd.d/rsync does not exist 7 : debmirror package is not installed, it will be required to manage debian deployments and repositories 8 : The default password used by the sample templates 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 are required to use the (optional) power management features. install cman or fence-agents to use them Restart cobblerd and then run ‘cobbler sync‘ to apply changes. [root@localhost cobbler]# grep "^server" settings #第一个问题的解决方案 server: 172.16.61.2 #指向本地可以与外界通信的地址 [root@localhost cobbler]# grep "^next_server" settings #第二个问题的解决 next_server: 172.16.61.2 #指向tftp地址 [root@localhost cobbler]# grep "^default_password" settings #第八个问题的解决 default_password_crypted: "$6$2Mf6mBdf$zoPVM3cv2Vgx4VIwSMJWSrIqYquBT1O686shIJEBYfmq3od9lgWtq301r39wkn8.gJrBI/oaWYU93kmXRbduP/" [root@localhost cobbler]# cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/cobbler/loaders/ #第五个问题的解决方案 [root@localhost cobbler]# cobbler sync #执行cobbler sync task started: 2016-02-23_140634_sync task started (id=Sync, time=Tue Feb 23 14:06:34 2016) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/pxelinux.cfg/default removing: /var/lib/tftpboot/grub/images removing: /var/lib/tftpboot/grub/efidefault removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk copying distros to tftpboot copying images generating PXE configuration files generating PXE menu structure rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running shell triggers from /var/lib/cobbler/triggers/sync/post/* running python triggers from /var/lib/cobbler/triggers/change/* running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
二、配置dhcp服务
option domain-name "tz.com"; option domain-name-servers 172.16.0.1; default-lease-time 3600; max-lease-time 7200; log-facility local7; subnet 172.16.0.0 netmask 255.255.0.0 { range 172.16.61.1 172.16.61.61; option routers 172.16.61.2; filename "pxelinux.0"; next-server 172.16.61.2; } [root@localhost cobbler]# systemctl start dhcpd #启动dhcp服务
三、管理cobbler
[root@localhost cobbler]# cobbler import --help #使用import命令将光盘制作为distro Usage: cobbler [options] Options: -h, --help show this help message and exit --arch=ARCH OS architecture being imported --breed=BREED the breed being imported --os-version=OS_VERSION the version being imported --path=PATH local path or rsync location --name=NAME name, ex ‘RHEL-5‘ --available-as=AVAILABLE_AS tree is here, don‘t mirror --kickstart=KICKSTART_FILE assign this kickstart file --rsync-flags=RSYNC_FLAGS pass additional flags to rsync [root@localhost cobbler]# cobbler import --name="CentOS-7-X86-64-1503" --path=/media/cdrom task started: 2016-02-23_142932_import task started (id=Media import, time=Tue Feb 23 14:29:32 2016) [root@localhost ~]# ls /var/www/cobbler/ks_mirror/ #在该目录下生成我们指定的文件 CentOS-7-X86-64-1503 config [root@localhost cobbler]# cobbler distro list #生成的distro CentOS-7-X86-64-1503-x86_64 [root@localhost cobbler]# cobbler profile list #生成的profile文件 CentOS-7-X86-64-1503-x86_64
注:cobbler会根据profile自动生成kickstart文件
测试结果:
四、cobbler_web
[root@localhost ~]# yum install -y cobbler-web #安装cobbler-web [root@localhost ~]# vim /etc/cobbler/modules.conf [authentication] module = authn_configfile #基于configfile认证 [root@localhost ~]# htdigest -c /etc/cobbler/users.digest Cobbler cobbleradmin #生成管理员用户与密码 Adding password for cobbleradmin in realm Cobbler. New password: Re-type new password: [root@localhost ~]# systemctl restart cobblerd
测试结果:
原文地址:http://tz666.blog.51cto.com/10990100/1744421