- 介绍
- cobbler 安装
Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
cobbler官网地址:官网.
cobbler集成的服务
- PXE服务支持
- DHCP服务管理
- DNS服务管理(可选bind,dnsmasq)
- 电源管理
- Kickstart服务支持
- YUM仓库管理
- TFTP(PXE启动时需要)
- Apache(提供kickstart的安装源,并提供定制化的kickstart配置)
#配置epel源
[root@localhost ~]# dnf install epel-release
#安装cobbler以及相关的软件
[root@localhost ~]# dnf module enable cobbler
[root@localhost ~]# dnf install cobbler
[root@localhost ~]# dnf -y install dhcp-* tftp xinetd pykickstart cobbler-web syslinux
#设置开机自启
[root@localhost ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl enable --now cobblerd
Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service → /usr/lib/systemd/system/cobblerd.service.
#修改server的IP为本机IP
[root@localhost ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.8.132/' /etc/cobbler/settings.yaml
#设置tftp的ip地址为本机ip
[root@localhost ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.8.132/' /etc/cobbler/settings.yaml
#修改文件
[root@localhost ~]# cat /etc/cobbler/settings.d/manage_genders.settings
# manage_genders - Bool to enable/disable managing an /etc/genders file for use with pdsh and others.
manage_genders: True #将flase修改True
[root@localhost ~]# cat /etc/cobbler/settings.d/nsupdate.settings
# Set to "true" to enable Cobbler's dynamic DNS updates.
nsupdate_enabled: True #将flase修改True
#下载缺失文件
[root@localhost ~]# cobbler get-loaders
task started: 2021-10-12_223104_get_loaders
task started (id=Download Bootloader Content, time=Tue Oct 12 22:31:04 2021)
running python triggers from /var/lib/cobbler/triggers/task/get_loaders/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/get_loaders/pre/*
shell triggers finished successfully
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
#生成加密密码
[root@localhost ~]# openssl passwd -1
Password:
Verifying - Password:
$1$Pke3JWSn$RwDn2joTPzf6QdwGfO/l7/
#将新生成的加密密码加入到配置文件
[root@localhost ~]# vim /etc/cobbler/settings.yaml
default_password_crypted: "$1$Pke3JWSn$RwDn2joTPzf6QdwGfO/l7/"
#重启cobbler
[root@localhost ~]# systemctl restart cobblerd
#配置dhcp
[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.8.0 netmask 255.255.255.0 {
option routers 192.168.8.132;
option domain-name-servers 192.168.8.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.8.100 192.168.8.254;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
#检查问题
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:
1: debmirror package is not installed, it will be required to manage debian deployments and repositories
2: 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 check
The following are potential configuration items that you may want to fix:
1: debmirror package is not installed, it will be required to manage debian deployments and repositories
Restart cobblerd and then run 'cobbler sync' to apply changes.
[root@localhost ~]# dnf -y install fence-agents
[root@localhost ~]# dnf -y install yum-utils
[root@localhost ~]# cobbler sync
task started: 2021-10-13_230634_sync
task started (id=Sync, time=Wed Oct 13 23:06:34 2021)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/grub.cfg
removing: /var/lib/tftpboot/grub/local_efi.cfg
removing: /var/lib/tftpboot/grub/local_legacy.cfg
removing: /var/lib/tftpboot/grub/local_powerpc-ieee1275.cfg
copying bootloaders
running: ['rsync', '-rpt', '--copy-links', '--exclude=.cobbler_postun_cleanup', '/var/lib/cobbler/loaders/', '/var/lib/tftpboot']
received on stdout:
received on stderr:
running: ['rsync', '-rpt', '--copy-links', '--exclude=README.grubconfig', '/var/lib/cobbler/grub_config/', '/var/lib/tftpboot']
received on stdout:
received on stderr:
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
cleaning link caches
running post-sync triggers
#导入镜像
[root@localhost ~]# mount /dev/cdrom /mnt/
[root@localhost ~]# cobbler import --name=centos8 --arch=x86_64 --path=/mnt
task started: 2021-10-13_231256_import
task started (id=Media import, time=Wed Oct 13 23:12:56 2021)
running python triggers from /var/lib/cobbler/triggers/task/import/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/import/pre/*
shell triggers finished successfully
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/distro_mirror/centos8-x86_64:
creating new distro: centos8-x86_64
trying symlink: /var/www/cobbler/distro_mirror/centos8-x86_64 -> /var/www/cobbler/links/centos8-x86_64
creating new profile: centos8-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/distro_mirror/centos8-x86_64 for centos8-x86_64
processing repo at : /var/www/cobbler/distro_mirror/centos8-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/centos8-x86_64/AppStream
looking for /var/www/cobbler/distro_mirror/centos8-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/centos8-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/centos8-x86_64/baseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/centos8-x86_64/baseOS
looking for /var/www/cobbler/distro_mirror/centos8-x86_64/baseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/centos8-x86_64/baseOS/repodata
#说明
--path #镜像路径
--name #为安装源定义名字
--arch #指定安装平台
#查看镜像列表
[root@localhost ~]# cobbler list
distros:
centos8-x86_64
profiles:
centos8-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
[root@localhost templates]# cobbler profile report centos8-x86_64
Name : centos8-x86_64
Automatic Installation Template : sample.ks
Automatic Installation metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : centos8-x86_64
Enable gPXE? : False
Enable PXE Menu? : True
Fetchable Files : {}
DHCP Filename Override : <>
Kernel Options : {}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <>
Repos : []
Server Override : <>
Template Files : {}
Virt Auto Boot : True
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
#创建kickstarts自动安装脚本
[root@localhost ~]# cat > /var/lib/cobbler/templates/centos8.ks < /var/lib/tftpboot/images/centos8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/centos8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos8-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos8-x86_64
trying hardlink /var/www/cobbler/distro_mirror/centos8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/centos8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos8-x86_64/initrd.img
Writing template files for centos8-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
#重启服务
[root@localhost templates]# systemctl restart cobblerd.service
[root@localhost templates]# systemctl restart httpd



