centos7 安装 cobbler 实现无人值守装机

一.安装

安装 epel-release, CentOS 自带的 yum repo 中不带有 cobbler 与 cobbler-web:

yum install epel-release

安装 cobbler 与依赖:

 yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web

Running transaction check
 cobbler                                         x86_64                   2.8.4-4.el7                                  epel                      578 k
 cobbler-web                                     noarch                   2.8.4-4.el7                                  epel                      289 k
Installing for dependencies:
 PyYAML                                          x86_64                   3.10-11.el7                                  base                      153 k
 libyaml                                         x86_64                   0.1.4-11.el7_0                               base                       55 k
 mod_ssl                                         x86_64                   1:2.4.6-89.el7.centos                        updates                   112 k
 mod_wsgi                                        x86_64                   3.4-18.el7                                   base                       77 k
 python-cheetah                                  x86_64                   2.4.4-5.el7.centos                           extras                    341 k
 python-django-bash-completion                   noarch                   1.11.21-1.el7                                epel                      9.9 k
 python-netaddr                                  noarch                   0.7.5-9.el7                                  base                      983 k
 python-pillow                                   x86_64                   2.0.0-19.gitd1c6db8.el7                      base                      438 k
 python-pygments                                 noarch                   1.4-10.el7                                   base                      599 k
 python2-django                                  noarch                   1.11.21-1.el7                                epel                      4.2 M
 python2-markdown                                noarch                   2.4.1-4.el7                                  epel                      250 k
 python2-pyyaml                                  noarch                   3.10-0.el7                                   epel                      3.0 k
 python2-simplejson                              x86_64                   3.10.0-2.el7                                 epel                      188 k
 syslinux                                        x86_64                   4.05-15.el7                                  base                      990 k 
tftp-server x86_64 5.2-22.el7 base 47 k Transaction Summary ======================================================================================================================================================= Install 2 Packages (+15 Dependent packages)

关闭防火墙、关闭selinux:

systemctl stop firewalld 
systemctl disable firewalld setenforce 0
sed -ri 's/(^SELINUX=).*/\1disabled/g' /etc/selinux/config

下载cobbler 缺失文件:

systemctl start cobblerd
systemctl start httpd
cobbler get-loaders

二.配置

修改配置文件:

/etc/xinetd.d/tftp

# 1) 修改为 no

disable                 = yes

/etc/cobbler/settings

# 1) 修改为本机 IP

server: 127.0.0.1

next_server: 127.0.0.1

# 2) 修改为 1

manage_dhcp: 0

# 3) 修改为使用 openssl passwd -1 -salt "$RANDOM" "passwd" 生成的密码

default_password_crypted:xxx

/etc/cobbler/dhcp.template

1) 将 option routers 与 option domain-name-servers 修改为本机 IP

 

 

 

 

 

 

 

 

 

 

 

 

 

 

启动并允许开机自启各种服务:

systemctl enable xinetd dhcpd httpd rsyncd cobblerd
systemctl restart xinetd dhcpd httpd rsyncd cobblerd

导入镜像:

# /mnt/iso 中已经有系统镜像
cobbler import --path=/mnt/iso --name=CentOS-7.4-1708 --arch=x86_64
# 列出镜像
cobbler list
cobbler profile list
cobbler profile report
[root@localhost ~]# cobbler profile list                                                                                                               
   CentOS-7.4-1708-x86_64
[root@localhost ~]# cobbler profile edit --name CentOS-7.4-1708-x86_64 --kickstart=/var/lib/cobbler/kickstarts/legacy.ks                               
[root@localhost ~]# cobbler profile report                     # 或者 cobbler distro report --name=CentOS-7.4-1708-x86_64 
Name                           : CentOS-7.4-1708-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : CentOS-7.4-1708-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/legacy.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 : 
Internal proxy                 : 
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      : 
Virt RAM (MB)                  : 512
Virt Type                      : kvm

配置自己的 kickstart 文件到 /var/lib/cobbler/kickstarts:

cobbler profile edit --name CentOS-7.4-1708-x86_64 --kickstart=/var/lib/cobbler/kickstarts/legacy.ks

修改需要同步一下: cobbler sync

注意:

  1. ks 中一定要指定从网络安装,并指明 url 路径: url --url=$tree ;
  2. 一般 /root/anaconda-ks.cfg 文件中指明的安装方式为: cdrom ,url 需要在 cdrom 之后出现,后来者覆盖;

至此已经可以通过 pxe 安装系统了。

三.web 访问:

https://<ip>/cobbler_web (账号密码均为 cobbler) 不可用,需要如此如此(参考)

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip install Django==1.8.9
pip install ipaddress
systemctl restart httpd
通过 yum 安装的 django 为 1.11.21,反而不如 1.8.9 能用:
[root@localhost ~]# pip install Django==1.8.9 DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Collecting Django==1.8.9 Downloading https://files.pythonhosted.org/packages/a7/a2/f4e7926062f5c61d98e87b9d0365ca1a0fab6be599dbea90ce2fab27f395/Django-1.8.9-py2.py3-none-any.whl (6.2MB) |████████████████████████████████| 6.2MB 112kB/s Installing collected packages: Django Found existing installation: Django 1.11.21 Uninstalling Django-1.11.21: Successfully uninstalled Django-1.11.21 Successfully installed Django-1.8.9

四.要点总结

  1. kickstart 文件中一定要有 url 指明从网络启动;
  2. /etc/cobbler/modules.conf 文件中不能有行内注释;(可以如此后,systemctl restart cobblerd && cobbler check  即可发现不妥)
  3. 要先有网卡 ip,/etc/cobbler/setting 文件中的 server 字段指出的 ip 一定要已经配置好,否则:
[root@localhost ~]# cobbler check                                                                                                                      
^Chttpd 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 1301, in single_request
    self.send_content(h, request_body)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1448, in send_content
    connection.endheaders(request_body)
  File "/usr/lib64/python2.7/httplib.py", line 1037, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python2.7/httplib.py", line 881, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.7/httplib.py", line 843, in send
    self.connect()
  File "/usr/lib64/python2.7/httplib.py", line 824, in connect
    self.timeout, self.source_address)  File "/usr/lib64/python2.7/socket.py", line 562, in create_connection
    sock.connect(sa)
  File "/usr/lib64/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
KeyboardInterrupt

cobbler 安装与配置参考:

cobbler

Centos7 下cobbler安装及配置

posted on 2019-10-09 19:15  森森南山  阅读(40)  评论(0)    收藏  举报