环境准备操作系统：Centos 7 1810安装方式：YUM配置epel的YUM源安装cobbleryum install cobbler cobbler-web pykickstart httpd dhcp tftp-server启动httpd、tftp、cobblerd服务，并设置为开机启动systemctl start cobblerd systemctl start httpd systemctl start tftp #设置相关服务开机启动 systemctl enable cobblerd systemctl enable httpd systemctl enable tftp systemctl enable rsyncd配置cobbler执行cobbler check命令检查cobbler设置这里可能会报如下错误httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 251, in check_setup s.ping() File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__ return self.__send(self.__name, args) File "/usr/lib64/python2.7/xmlrpclib.py", line 1591, in __request verbose=self.__verbose File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib64/python2.7/xmlrpclib.py", line 1321, in single_request response.msg, ProtocolError: <ProtocolError for 127.0.0.1:80/cobbler_api: 503 Service Unavailable>根据提示，可以确定是selinux引起的问题，可以将selinux关掉或者执行如下操作setsebool -P httpd_can_network_connect true这里建议关掉selinux，如果不想关的话，则参考如下链接的设置方法https://github.com/cobbler/cobbler/wiki/Selinux再次执行cobbler check命令检查，输出信息如下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 : debmirror package is not installed, it will be required to manage debian deployments and repositories 7 : 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 8 : 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.下面我们便依据以上检查出的问题逐项进行修复及配置修改配置文件/etc/cobbler/settings （问题1、2）#更改监听IP。 sed -i 's/server: 127.0.0.1/server: 172.25.68.8/' /etc/cobbler/settings #next_server，用Cobbler管理DHCP需要修改此项。 sed -i 's/next_server: 127.0.0.1/next_server: 172.25.68.8/' /etc/cobbler/settings #用Cobbler管理DHCP。 sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings #防止循环装系统。 sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings关闭或设置selinux（问题3）#临时关闭selinux setenforce 0 #永久关闭selinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config修改tftp相关设置（问题4）编辑配置文件/etc/xinetd.d/tftp，如果里面是disable=yes的话，需要修改为disable=no同步cobbler设置（问题5）执行如下命令，从github上同步cobbler需要用到的一些引导文件及加载项cobbler get-loaders安装debian系统相关支持（问题6）yum -y install debmirror修改默认密码（问题7）这里设置的密码是使用cobbler默认安装的操作系统的密码，用如下命令生成，其中random-phrase-here为干扰码，可以自行设置，your-password-here为自己设置的密码，执行完成后，用生成的值将/etc/cobbler/settings中default_password_crypted的值替换掉即可。openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'"安装fence相关设备支持（问题8）yum -y install fence-agents再次重启cobblerd服务并执行cobbler check进行配置项检查检查还有如下的报错The following are potential configuration items that you may want to fix: 1 : comment out 'dists' on /etc/debmirror.conf for proper debian support 2 : comment out 'arches' on /etc/debmirror.conf for proper debian support Restart cobblerd and then run 'cobbler sync' to apply changes.解决办法：将/etc/debmirror.conf配置文件中包含@dists和@arches的两行注释掉即可再次检查已经没有报错DHCP的配置由于上文中已经配置由cobbler管理DHCP，因此，DHCP的配置就应该使用cobbler的模板来生成，我们直接修改/etc/cobbler/dhcp.template文件即可，这里需要注意的一点就是DHCP的配置必须要有一段包含本子网的配置，否则DHCP会报错。新增的网段直接复制subnet相关的配置就行Cobbler命令行的使用Cobbler Web的使用上文中已经安装过cobbler-web了，因此，只要启动httpd服务，cobbler web服务便可以使用了。新版的cobbler web界面需要用HTTPS来访问，访问地址是https://ip/cobbler_web但是，我们在访问的时候，发现服务器报500错误，经过检查httpd的日志，发现报错如下：[Thu Jan 24 16:01:25.739471 2019] [:error] [pid 5466] [remote 172.25.120.32:96] mod_wsgi (pid=5466): Exception occurred processing WSGI script '/usr/share/cobbler/web/cobbler.wsgi'. [Thu Jan 24 16:01:25.739567 2019] [:error] [pid 5466] [remote 172.25.120.32:96] Traceback (most recent call last): [Thu Jan 24 16:01:25.739618 2019] [:error] [pid 5466] [remote 172.25.120.32:96] File "/usr/share/cobbler/web/cobbler.wsgi", line 26, in application [Thu Jan 24 16:01:25.739687 2019] [:error] [pid 5466] [remote 172.25.120.32:96] _application = get_wsgi_application() [Thu Jan 24 16:01:25.739719 2019] [:error] [pid 5466] [remote 172.25.120.32:96] File "/usr/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application [Thu Jan 24 16:01:25.739753 2019] [:error] [pid 5466] [remote 172.25.120.32:96] django.setup(set_prefix=False) [Thu Jan 24 16:01:25.739768 2019] [:error] [pid 5466] [remote 172.25.120.32:96] File "/usr/lib/python2.7/site-packages/django/__init__.py", line 22, in setup [Thu Jan 24 16:01:25.739791 2019] [:error] [pid 5466] [remote 172.25.120.32:96] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) [Thu Jan 24 16:01:25.739804 2019] [:error] [pid 5466] [remote 172.25.120.32:96] File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__ [Thu Jan 24 16:01:25.739826 2019] [:error] [pid 5466] [remote 172.25.120.32:96] self._setup(name) [Thu Jan 24 16:01:25.739843 2019] [:error] [pid 5466] [remote 172.25.120.32:96] File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup [Thu Jan 24 16:01:25.739907 2019] [:error] [pid 5466] [remote 172.25.120.32:96] self._wrapped = Settings(settings_module) [Thu Jan 24 16:01:25.739933 2019] [:error] [pid 5466] [remote 172.25.120.32:96] File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__ [Thu Jan 24 16:01:25.739955 2019] [:error] [pid 5466] [remote 172.25.120.32:96] mod = importlib.import_module(self.SETTINGS_MODULE) [Thu Jan 24 16:01:25.739968 2019] [:error] [pid 5466] [remote 172.25.120.32:96] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module [Thu Jan 24 16:01:25.739990 2019] [:error] [pid 5466] [remote 172.25.120.32:96] __import__(name) [Thu Jan 24 16:01:25.740032 2019] [:error] [pid 5466] [remote 172.25.120.32:96] File "/usr/share/cobbler/web/settings.py", line 89, in <module> [Thu Jan 24 16:01:25.740062 2019] [:error] [pid 5466] [remote 172.25.120.32:96] from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS [Thu Jan 24 16:01:25.740298 2019] [:error] [pid 5466] [remote 172.25.120.32:96] ImportError: cannot import name TEMPLATE_CONTEXT_PROCESSORS这个报错是由于centos 7默认安装的python-django版本过高，cobbler还存在一些bug未修复，因此，我们需要将djaogo框架降到低版本。首先，查询当前系统安装的django版本rpm -qa |grep django然后卸载rpm -e python2-django-1.11.18-1.el7.noarch --nodeps安装较低版本的djangoyum -y install python2-django16重启httpd服务systemctl restart httpd自定义的kickstart文件