2023年12月27日

cobbler 介绍与安装

作者 高劲松

Cobbler是一个使用Python开发的开源项目,通过将部署系统所涉及的所有服务集中在一起,来提供一个全自动批量快速建立Linux系统的网络安装环境。

Cobbler提供了DHCP管理、YUM源管理、电源管理等功能,还支持命令行管理、WEB界面管理,并且提供了API接口,方便二次开发。

Cobbler是一款Linux生态的自动化运维工具,基于Python2开发,用于自动化批量部署安装操作系统;其提供基于CLI的管理方式和WEB配置界面,其中WEB配置界面是基于Python2和Django框架开发。另外,cobbler还提供了API,方便二次开发。当然,Cobbler属于C/S模型(客户端/服务器模型)

Cobbler主要用于快速网络安装linux操作系统,支持众多的Linux发行版如:Red Hat、
Fedora、CentOS、Debian、Ubuntu和SuSE等。

在cobbler之前,微软曾开发过另一项类似的基于C/S工作模式的技术PXE(Prebot eXecuteEnvironment,预启动执行环境),其支持通过网络启动操作系统,亦可以让需要安装系统的带支持PEX技术网卡的裸机通过网络从http服务器下载映像来安装,在启动过程中,客户端需要从dhcp服务器得到IP地址、掩码、网关以及相关的配置文件路径,再用TFTP(trivial file transferprotocol)协议从服务器下载一个引导启动的软件包(类似linux光盘的isolinux文件夹下的文件)并加载到本机内存中执行,经过启动软件包中配置文件指定的ks应答文件指明服务器中的操作系统位置,进而找到安装源,并在ks文件的指导下完成操作系统的安装。

Cobbler实质是PXE的二次封装,将多种安装参数封装到一起,并提供统一的管理方法。

Last login: Wed Dec 27 06:40:45 2023
[root@localhost ~]# systemctl status firewalld.service
● firewalld.service – firewalld – dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-12-27 06:38:33 EST; 5h 11min left
Docs: man:firewalld(1)
Main PID: 719 (firewalld)
CGroup: /system.slice/firewalld.service
└─719 /usr/bin/python2 -Es /usr/sbin/firewalld –nofork –nopid

Dec 27 06:38:32 localhost.localdomain systemd[1]: Starting firewalld – dynamic firewall daemon…
Dec 27 06:38:33 localhost.localdomain systemd[1]: Started firewalld – dynamic firewall daemon.
Dec 27 06:38:33 localhost.localdomain firewalld[719]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure… now.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
curl: (22) The requested URL returned error: 404 Not Found
error: skipping http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm – transfer failed
[root@localhost ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.ustc.edu.cn
    No package cobbler available.
    No package cobbler-web available.

    Resolving Dependencies
    –> Running transaction check
    —> Package dhcp.x86_64 12:4.2.5-83.el7.centos.1 will be installed
    –> Processing Dependency: dhcp-libs(x86-64) = 12:4.2.5-83.el7.centos.1 for package: 12:dhcp-4.2.5-83.el7.centos.1.x86_64
    –> Processing Dependency: dhcp-common = 12:4.2.5-83.el7.centos.1 for package: 12:dhcp-4.2.5-83.el7.centos.1.x86_64
    —> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be installed
    –> Processing Dependency: httpd-tools = 2.4.6-99.el7.centos.1 for package: httpd-2.4.6-99.el7.centos.1.x86_64
    –> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================

Package Arch Version Repository Size

Installing:
dhcp x86_64 12:4.2.5-83.el7.centos.1 updates 515 k
httpd x86_64 2.4.6-99.el7.centos.1 updates 2.7 M
tftp x86_64 5.2-22.el7 base 38 k
xinetd x86_64 2:2.3.15-14.el7 base 128 k
Updating:
python x86_64 2.7.5-94.el7_9 updates 97 k
Installing for dependencies:
apr x86_64 1.4.8-7.el7 base 104 k
apr-util x86_64 1.5.2-6.el7_9.1 updates 92 k
httpd-tools x86_64 2.4.6-99.el7.centos.1 updates 94 k
mailcap noarch 2.1.41-2.el7 base 31 k
Updating for dependencies:
dhclient x86_64 12:4.2.5-83.el7.centos.1 updates 286 k
dhcp-common x86_64 12:4.2.5-83.el7.centos.1 updates 177 k
dhcp-libs x86_64 12:4.2.5-83.el7.centos.1 updates 133 k
python-libs x86_64 2.7.5-94.el7_9 updates 5.6 M

Transaction Summary

Install 4 Packages (+4 Dependent packages)
Upgrade 1 Package (+4 Dependent packages)

Total download size: 10 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/13): apr-1.4.8-7.el7.x86_64.rpm | 104 kB 00:00:00
(2/13): dhcp-common-4.2.5-83.el7.centos.1.x86_64.rpm | 177 kB 00:00:00
(3/13): apr-util-1.5.2-6.el7_9.1.x86_64.rpm | 92 kB 00:00:00
(4/13): dhclient-4.2.5-83.el7.centos.1.x86_64.rpm | 286 kB 00:00:00
(5/13): httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm | 94 kB 00:00:00
(6/13): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00
(7/13): python-2.7.5-94.el7_9.x86_64.rpm | 97 kB 00:00:00
(8/13): dhcp-4.2.5-83.el7.centos.1.x86_64.rpm | 515 kB 00:00:00
(9/13): xinetd-2.3.15-14.el7.x86_64.rpm | 128 kB 00:00:00
(10/13): dhcp-libs-4.2.5-83.el7.centos.1.x86_64.rpm | 133 kB 00:00:01
(11/13): httpd-2.4.6-99.el7.centos.1.x86_64.rpm | 2.7 MB 00:00:01
(12/13): tftp-5.2-22.el7.x86_64.rpm | 38 kB 00:00:02

(13/13): python-libs-2.7.5-94.el7_9.x86_64.rpm | 5.6 MB 00:00:03

Total 2.2 MB/s | 10 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 12:dhcp-libs-4.2.5-83.el7.centos.1.x86_64 1/18
Installing : apr-1.4.8-7.el7.x86_64 2/18
Installing : apr-util-1.5.2-6.el7_9.1.x86_64 3/18
Updating : 12:dhcp-common-4.2.5-83.el7.centos.1.x86_64 4/18
Verifying : 12:dhclient-4.2.5-82.el7.centos.x86_64 16/18
Verifying : 12:dhcp-libs-4.2.5-82.el7.centos.x86_64 17/18
Verifying : python-2.7.5-89.el7.x86_64 18/18

Installed:
dhcp.x86_64 12:4.2.5-83.el7.centos.1 httpd.x86_64 0:2.4.6-99.el7.centos.1 tftp.x86_64 0:5.2-22.el7 xinetd.x86_64 2:2.3.15-14.el7

Dependency Installed:
apr.x86_64 0:1.4.8-7.el7 apr-util.x86_64 0:1.5.2-6.el7_9.1 httpd-tools.x86_64 0:2.4.6-99.el7.centos.1
mailcap.noarch 0:2.1.41-2.el7

Updated:
python.x86_64 0:2.7.5-94.el7_9

Dependency Updated:
dhclient.x86_64 12:4.2.5-83.el7.centos.1 dhcp-common.x86_64 12:4.2.5-83.el7.centos.1 dhcp-libs.x86_64 12:4.2.5-83.el7.centos.1
python-libs.x86_64 0:2.7.5-94.el7_9

Complete!
[root@localhost ~]# rpm -vih https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-13.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-13.noarch.rpm
curl: (22) The requested URL returned error: 404 Not Found
error: skipping https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-13.noarch.rpm – transfer failed
[root@localhost ~]# yum -y install epel*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.ustc.edu.cn
    Resolving Dependencies
    –> Running transaction check
    —> Package epel-release.noarch 0:7-11 will be installed
    –> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================

Package Arch Version Repository Size

Installing:
epel-release noarch 7-11 extras 15 k

Transaction Summary

Install 1 Package

Total download size: 15 k
Installed size: 24 k
Downloading packages:
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/1
Verifying : epel-release-7-11.noarch 1/1

Installed:
epel-release.noarch 0:7-11

Complete!
[root@localhost ~]# yum -y install cobbler cobbler-web
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 7.7 kB 00:00:00

  • base: mirrors.aliyun.com
  • epel: mirror.nyist.edu.cn
  • extras: mirrors.aliyun.com
  • updates: mirrors.ustc.edu.cn
    epel | 4.7 kB 00:00:00
    (1/3): epel/x86_64/group_gz | 99 kB 00:00:00
    (2/3): epel/x86_64/updateinfo | 1.0 MB 00:00:00
    (3/3): epel/x86_64/primary_db | 7.0 MB 00:00:04
    Resolving Dependencies
    –> Running transaction check
    —> Package cobbler.x86_64 0:2.8.5-6.el7 will be installed
    –> Processing Dependency: createrepo for package: cobbler-2.8.5-6.el7.x86_64
    –> Processing Dependency: python-imaging for package: python-pygments-1.4-10.el7.noarch
    —> Package python2-markdown.noarch 0:2.4.1-4.el7 will be installed
    —> Package pytz.noarch 0:2016.10-2.el7 will be installed
    –> Running transaction check
    —> Package python-backports.x86_64 0:1.0-8.el7 will be installed
    –> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================

Package Arch Version Repository Size

Installing:
cobbler x86_64 2.8.5-6.el7 epel 580 k
cobbler-web noarch 2.8.5-6.el7 epel 289 k
Installing for dependencies:
rsync x86_64 3.1.2-12.el7_9 updates 408 k
syslinux x86_64 4.05-15.el7 base 990 k
tftp-server x86_64 5.2-22.el7 base 47 k
yum-utils noarch 1.1.31-54.el7_8 base 122 k
Updating for dependencies:
libxml2 x86_64 2.9.1-6.el7_9.6 updates 668 k

Transaction Summary

Install 2 Packages (+32 Dependent packages)
Upgrade ( 1 Dependent package)

Total download size: 13 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/35): deltarpm-3.6-3.el7.x86_64.rpm | 82 kB 00:00:00
(2/35): PyYAML-3.10-11.el7.x86_64.rpm | 153 kB 00:00:00
(3/35): createrepo-0.9.9-28.el7.noarch.rpm | 94 kB 00:00:00
(4/35): libusal-1.1.11-25.el7.x86_64.rpm | 136 kB 00:00:00
(5/35): genisoimage-1.1.11-25.el7.x86_64.rpm | 299 kB 00:00:00
warning: /var/cache/yum/x86_64/7/epel/packages/cobbler-web-2.8.5-6.el7.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for cobbler-web-2.8.5-6.el7.noarch.rpm is not installed
(31/35): python2-simplejson-3.11.1-1.el7.x86_64.rpm | 188 kB 00:00:00
(32/35): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00
(33/35): rsync-3.1.2-12.el7_9.x86_64.rpm | 408 kB 00:00:00
(34/35): syslinux-4.05-15.el7.x86_64.rpm | 990 kB 00:00:00

(35/35): python2-django-1.11.27-1.el7.noarch.rpm | 4.2 MB 00:00:04

Total 2.0 MB/s | 13 MB 00:00:06
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
Userid : “Fedora EPEL (7) epel@fedoraproject.org
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Package : epel-release-7-11.noarch (@extras)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-ipaddress-1.0.16-2.el7.noarch 1/36
Installing : deltarpm-3.6-3.el7.x86_64 2/36
Installing : mod_wsgi-3.4-18.el7.x86_64 3/36
Installing : python-deltarpm-3.6-3.el7.x86_64 4/36
Installing : python2-markdown-2.4.1-4.el7.noarch 5/36
Installing : python-chardet-2.2.1-3.el7.noarch 6/36
Installing : python-kitchen-1.1.1-5.el7.noarch 7/36
Installing : python-netaddr-0.7.5-9.el7.noarch 8/36
Installing : libyaml-0.1.4-11.el7_0.x86_64 9/36
Verifying : python-pillow-2.0.0-23.gitd1c6db8.el7_9.x86_64 34/36
Verifying : genisoimage-1.1.11-25.el7.x86_64 35/36
Verifying : libxml2-2.9.1-6.el7.5.x86_64 36/36

Installed:
cobbler.x86_64 0:2.8.5-6.el7 cobbler-web.noarch 0:2.8.5-6.el7

Dependency Installed:
PyYAML.x86_64 0:3.10-11.el7 createrepo.noarch 0:0.9.9-28.el7
deltarpm.x86_64 0:3.6-3.el7 genisoimage.x86_64 0:1.1.11-25.el7
libusal.x86_64 0:1.1.11-25.el7 libwebp.x86_64 0:0.3.0-11.el7
libxml2-python.x86_64 0:2.9.1-6.el7_9.6 libyaml.x86_64 0:0.1.4-11.el7_0
mod_ssl.x86_64 1:2.4.6-99.el7.centos.1 mod_wsgi.x86_64 0:3.4-18.el7
mtools.x86_64 0:4.0.18-5.el7 python-backports.x86_64 0:1.0-8.el7
python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 python-chardet.noarch 0:2.2.1-3.el7
python-deltarpm.x86_64 0:3.6-3.el7 python-django-bash-completion.noarch 0:1.11.27-1.el7
python-ipaddress.noarch 0:1.0.16-2.el7 python-kitchen.noarch 0:1.1.1-5.el7
python-netaddr.noarch 0:0.7.5-9.el7 python-pillow.x86_64 0:2.0.0-23.gitd1c6db8.el7_9
python-pygments.noarch 0:1.4-10.el7 python-setuptools.noarch 0:0.9.8-7.el7
python2-cheetah.x86_64 0:2.4.4-6.el7 python2-django.noarch 0:1.11.27-1.el7
python2-markdown.noarch 0:2.4.1-4.el7 python2-pyyaml.noarch 0:3.10-0.el7
python2-simplejson.x86_64 0:3.11.1-1.el7 pytz.noarch 0:2016.10-2.el7
rsync.x86_64 0:3.1.2-12.el7_9 syslinux.x86_64 0:4.05-15.el7
tftp-server.x86_64 0:5.2-22.el7 yum-utils.noarch 0:1.1.31-54.el7_8

Dependency Updated:
libxml2.x86_64 0:2.9.1-6.el7_9.6

Complete!

[root@localhost ~]# clear
[root@localhost ~]# service iptables stop
Redirecting to /bin/systemctl stop iptables.service
Failed to stop iptables.service: Unit iptables.service not loaded.
[root@localhost ~]# set enforce 0

[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl enable cobblerd
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
[root@localhost ~]# systemctl start cobblerd
[root@localhost ~]# cobbler check
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:
[root@localhost ~]#