cobbler批量装机工具
文章目录
- cobbler批量装机工具
- 1. cobbler简介
- 2. cobbler服务端部署uos
- 3. 客户端安装(内存和cpu可以多个点,以免后面出错)
- 4.cobbler服务端部署centos7
- 5.客户端安装
- 6.cobbler服务端部署centos8
- 7.客户端安装
- 8.cobbler服务端部署rockylinux9
- 9.客户端安装
- 10.定制安装
1. 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配置)
cobbler配置文件详解
cobbler
配置文件目录在/etc/cobbler
配置文件 | 作用 |
---|---|
/etc/cobbler/settings | cobbler 主配置文件 |
/etc/cobbler/iso/ | iso模板配置文件 |
/etc/cobbler/pxe | pxe模板配置文件 |
/etc/cobbler/power | 电源配置文件 |
/etc/cobbler/user.conf | web服务授权配置文件 |
/etc/cobbler/users.digest | web访问的用户名密码配置文件 |
/etc/cobbler/dhcp.template | dhcp服务器的的配置模板 |
/etc/cobbler/dnsmasq.template | dns服务器的配置模板 |
/etc/cobbler/tftpd.template | tftp服务的配置模板 |
/etc/cobbler/modules.conf | 模块的配置文件 |
cobbler数据目录
目录 | 作用 |
---|---|
/var/lib/cobbler/config/ | 用于存放distros,system,profiles等信息配置文件 |
/var/lib/cobbler/triggers/ | 用于存放用户定义的cobbler命令 |
/var/lib/cobbler/kickstart/ | 默认存放kickstart文件 |
/var/lib/cobbler/loaders/ | 存放各种引导程序以及镜像目录 |
/var/www/cobbler/ks_mirror/ | 导入的发行版系统的所有数据 |
/var/www/cobbler/images/ | 导入发行版的kernel和initrd镜像用于远程网络启动 |
/var/www/cobbler/repo_mirror/ | yum仓库存储目录 |
cobbler日志文件
日志文件路径 | 说明 |
---|---|
/var/log/cobbler/installing | 客户端安装日志 |
/var/log/cobbler/cobbler.log | cobbler日志 |
cobbler
命令详解
cobbler check //核对当前设置是否有问题
cobbler list //列出所有的cobbler元素
cobbler report //列出元素的详细信息
cobbler sync //同步配置到数据目录,更改配置最好都要执行下
cobbler reposync //同步yum仓库
cobbler distro //查看导入的发行版系统信息
cobbler system //查看添加的系统信息
cobbler profile //查看配置信息
2. cobbler服务端部署uos
服务端主机空间要求
1.关闭防火墙
[root@cobbler ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@cobbler ~]# getenforce
Disabled2.安装cobbler以及相关的软件
[root@cobbler ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart
UnionTechOS 20 AppStream 1.3 MB/s | 8.1 MB 00:05
UnionTechOS 20 BaseOS 2.0 MB/s | 1.8 MB 00:00
UnionTechOS 20 PowerTools 2.6 MB/s | 2.8 MB 00:01
UnionTechOS 20 Plus 8.0 MB/s | 10 MB 00:01
UnionTechOS 20 Extras 9.1 kB/s | 2.3 kB 00:00
UnionTechOS 20 Update 1.0 kB/s | 257 B 00:00
UnionTechOS 20 GM 3.4 MB/s | 1.4 MB 00:00
未找到匹配的参数: dhcp
未找到匹配的参数: python-ctypes
错误:没有任何匹配: dhcp python-ctypes//解决方案
[root@cobbler ~]# yum list all | grep python|grep ctypes
[root@cobbler ~]# yum -y install httpd dhcp* tftp cobbler xinetd cobbler-web pykickstart syslinux
完毕!3.启动服务并设置开机自启
[root@cobbler ~]# systemctl enable --now httpd cobblerd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service → /usr/lib/systemd/system/cobblerd.service.4.修改server的ip地址为本机ip
[root@cobbler ~]# vim /etc/cobbler/settings
server: 192.168.116.146 //改为自己本机的ip5.设置tftp的ip地址为本机ip
[root@cobbler ~]# vim /etc/cobbler/settings
next_server: 192.168.116.146 //改为自己本机的ip6.开启tftp
[root@cobbler ~]# systemctl enable --now tftp
Created symlink /etc/systemd/system/sockets.target.wants/tftp.socket → /usr/lib/systemd/system/tftp.socket.
[root@cobbler ~]# systemctl status tftp
● tftp.service - Tftp ServerLoaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled)Active: active (running) since Mon 2023-12-25 14:06:00 CST; 10s agoDocs: man:in.tftpdMain PID: 69394 (in.tftpd)Tasks: 1Memory: 108.0KCGroup: /system.slice/tftp.service└─69394 /usr/sbin/in.tftpd -s /var/lib/tftpboot12月 25 14:06:00 cobbler systemd[1]: Started Tftp Server.7.下载缺失文件
[root@cobbler ~]# cobbler get-loaders
task started: 2023-12-25_140649_get_loaders
task started (id=Download Bootloader Content, time=Mon Dec 25 14:06:49 2023)
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 ***8.启动rsync并设置开机自启
[root@cobbler ~]# rpm -qa | grep rsync
rsync-3.1.3-19.uelc20.x86_64
[root@cobbler ~]# yum -y install rsync-daemon
完毕!
[root@cobbler ~]# systemctl enable --now rsyncd
Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service → /usr/lib/systemd/system/rsyncd.service.
[root@cobbler ~]# systemctl status rsyncd
● rsyncd.service - fast remote file copy program daemonLoaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled)Active: active (running) since Mon 2023-12-25 14:09:05 CST; 6s agoMain PID: 93475 (rsync)Tasks: 1Memory: 188.0KCGroup: /system.slice/rsyncd.service└─93475 /usr/bin/rsync --daemon --no-detach12月 25 14:09:05 cobbler systemd[1]: Started fast remote file copy program daemon.
12月 25 14:09:05 cobbler rsyncd[93475]: rsyncd version 3.1.3 starting, listening on port 8739.生成加密的密码
[root@cobbler ~]# openssl passwd -1 -salt "$RANDOM" 'Passw0rd@_~'
$1$24272$8uLVuFlMwimkhkygX30rN0 //这是密码加密后的形式10.将新生成的加密密码加入到配置文件
[root@cobbler ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$24272$8uLVuFlMwimkhkygX30rN0" //改为刚刚生成的随机加密的密码11.重启cobbler
[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 5 127.0.0.1:25151 0.0.0.0:*
LISTEN 0 5 0.0.0.0:873 0.0.0.0:*
LISTEN 0 511 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 511 *:443 *:*
LISTEN 0 5 [::]:873 [::]:*
12.通过cobbler check 核对当前设置是否有问题
[root@cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:1: reposync is not installed, install yum-utils or dnf-plugins-core
2: yumdownloader is not installed, install yum-utils or dnf-plugins-core
3: debmirror package is not installed, it will be required to manage debian deployments and repositories
4: fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use themRestart cobblerd and then run 'cobbler sync' to apply changes.//解决方案
[root@cobbler ~]# yum -y install yum-utils
完毕![root@cobbler ~]# 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 themRestart cobblerd and then run 'cobbler sync' to apply changes.13.配置cobbler dhcp
//修改cobbler配置文件,让cobbler控制dhcp
[root@cobbler ~]# vim /etc/cobbler/settings
manage_dhcp: 114.配置dhcp
[root@cobbler ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.116.0 netmask 255.255.255.0 { //改为自己虚拟机的网段option routers 192.168.116.146; //改为自己虚拟机的ipoption domain-name-servers 192.168.116.2; //自己虚拟机的网关option subnet-mask 255.255.255.0;range dynamic-bootp 192.168.116.100 192.168.116.200;default-lease-time 21600;max-lease-time 43200;next-server $next_server;15.重启服务并同步配置,改完dhcp必须要sync同步配置
[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# cobbler sync
task started: 2023-12-25_142054_sync
task started (id=Sync, time=Mon Dec 25 14:20:54 2023)
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/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/images
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
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.servicerunning shell triggers from /var/lib/cobbler/triggers/sync/post/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***16.检查dhcp是否正常
[root@cobbler ~]# ss -anulp|grep dhcp
UNCONN 0 0 0.0.0.0:59154 0.0.0.0:* users:(("dhcpd",pid=144794,fd=20))
UNCONN 0 0 0.0.0.0:67 0.0.0.0:* users:(("dhcpd",pid=144794,fd=10))
UNCONN 0 0 [::]:40968 [::]:* users:(("dhcpd",pid=144794,fd=21)) 17.导入uos镜像
[root@cobbler ~]# mount /dev/cdrom /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@cobbler ~]# ls /mnt
AppStream BaseOS EFI extra_files.json images isolinux kernel419 kernel510 media.repo RPM-GPG-KEY-uos-release TRANS.TBL
[root@cobbler ~]# cobbler import --path=/mnt --name=uos20 --arch=x86_64
task started: 2023-12-25_142438_import
task started (id=Media import, time=Mon Dec 25 14:24:38 2023)
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=uniontech, version=uniontech
Found a matching signature: breed=uniontech, version=uniontech
Adding distros from path /var/www/cobbler/distro_mirror/uos20-x86_64:
creating new distro: uos20-x86_64
trying symlink: /var/www/cobbler/distro_mirror/uos20-x86_64 -> /var/www/cobbler/links/uos20-x86_64
creating new profile: uos20-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/uos20-x86_64 for uos20-x86_64
processing repo at : /var/www/cobbler/distro_mirror/uos20-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/uos20-x86_64/AppStream
looking for /var/www/cobbler/distro_mirror/uos20-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/uos20-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/uos20-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/uos20-x86_64/BaseOS
looking for /var/www/cobbler/distro_mirror/uos20-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/uos20-x86_64/BaseOS/repodata
processing repo at : /var/www/cobbler/distro_mirror/uos20-x86_64/kernel419
directory /var/www/cobbler/distro_mirror/uos20-x86_64/kernel419 is missing xml comps file, skipping
processing repo at : /var/www/cobbler/distro_mirror/uos20-x86_64/kernel510
directory /var/www/cobbler/distro_mirror/uos20-x86_64/kernel510 is missing xml comps file, skipping
*** TASK COMPLETE ***//说明:--path //镜像路径--name //为安装源定义一个名字--arch //指定安装源平台//安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:uos20-x86_64,如果重复,系统会提示导入失败18.查看cobbler镜像列表
[root@cobbler ~]# cobbler list
distros:uos20-x86_64profiles:uos20-x86_64systems:repos:images:mgmtclasses:packages:files:19.进入/var/lib/cobbler/templates目录创建一个以.ks结尾的文件生成自动安装脚本
[root@cobbler ~]# cd /var/lib/cobbler/
[root@cobbler cobbler]# ls
collections distro_signatures.json grub_config loaders lock scripts snippets templates triggers web.ss webui_sessions
[root@cobbler cobbler]# cd templates/
[root@cobbler templates]# ls
default.ks install_profiles pxerescue.ks sample_esxi5.ks sample_legacy.ks
esxi4-ks.cfg legacy.ks sample_autoyast.xml sample_esxi6.ks sample_old.seed
esxi5-ks.cfg powerkvm.ks sample_esxi4.ks sample.ks sample.seed
[root@cobbler templates]# pwd
/var/lib/cobbler/templates
[root@cobbler templates]# vim uos20.ks
[root@cobbler templates]# cat uos20.ks
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.116.146/cobbler/links/uos20-x86_64/ //这个到网页上面访问:ip/cobbler
$yum_repo_stanza
rebootrootpw --iscrypted $6$WqdLuLnm2W8M98bv$XKfgxxCeviKNg4y/pj6bT2/b/WIT.91YyWcb3930BgVUiuHXuFtqQXLP3isSdfz2mZpSQCDqO.Ude3uL9pz370 //这个位置可以复制自己虚拟机的/root/anaconda-ks.cfg中的selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr%packages
@^minimal
@core
kexec-tools%end%addon com_redhat_kdump --enable --reserve-mb='auto'%end%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end20.检查ks文件语法是否有误
[root@cobbler ~]# cobbler --help
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... [add|edit|copy|get-autoinstall*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validate-autoinstalls|version|signature|get-loaders|hardlink> [options|--help]
[root@cobbler ~]# cobbler validate-autoinstalls
task started: 2023-12-25_143648_validate_autoinstall_files
task started (id=Automated installation files validation, time=Mon Dec 25 14:36:48 2023)
running python triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
shell triggers finished successfully
*** TASK COMPLETE ***21.查看当前cobbler有哪些配置文件
[root@cobbler ~]# cobbler profile listuos20-x86_6422.修改profile,将我们新建的ks文件设为默认的autoinstall安装文件
[root@cobbler ~]# cobbler profile edit --help--autoinstall=AUTOINSTALLAutomatic Installation Template (Path to automaticinstallation template)
[root@cobbler ~]# cobbler profile edit --name uos20-x86_64 --autoinstall=uos20.ks23.配置网卡名称为传统网卡名称eth0
[root@cobbler ~]# cobbler profile edit --help
--kernel-options=KERNEL_OPTIONSKernel Options (Ex: selinux=permissive)
[root@cobbler ~]# cobbler profile edit --name uos20-x86_64 --kernel-options='net.ifnames=0 biosdevname=0'24.检查当前系统cobbler配置文件信息
[root@cobbler ~]# cobbler profile report
Name : uos20-x86_64
Automatic Installation Template : uos20.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : uos20-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {'net.ifnames': '0', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<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 : kvm25.同步cobbler
[root@cobbler ~]# cobbler sync
task started: 2023-12-25_144402_sync
task started (id=Sync, time=Mon Dec 25 14:44:02 2023)
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/www/cobbler/images/uos20-x86_64
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
removing: /var/lib/tftpboot/grub/aarch64_menu_items.cfg
removing: /var/lib/tftpboot/grub/i386_menu_items.cfg
removing: /var/lib/tftpboot/grub/x86_64_menu_items.cfg
removing: /var/lib/tftpboot/grub/ppc_menu_items.cfg
removing: /var/lib/tftpboot/grub/ppc64_menu_items.cfg
removing: /var/lib/tftpboot/grub/ppc64le_menu_items.cfg
removing: /var/lib/tftpboot/grub/loongarch64_menu_items.cfg
removing: /var/lib/tftpboot/grub/amd64_menu_items.cfg
removing: /var/lib/tftpboot/grub/ppc64el_menu_items.cfg
removing: /var/lib/tftpboot/grub/ia64_menu_items.cfg
removing: /var/lib/tftpboot/grub/s390_menu_items.cfg
removing: /var/lib/tftpboot/grub/s390x_menu_items.cfg
removing: /var/lib/tftpboot/grub/i586_menu_items.cfg
removing: /var/lib/tftpboot/images/uos20-x86_64
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 files for distro: uos20-x86_64
trying hardlink /var/www/cobbler/distro_mirror/uos20-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/uos20-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/uos20-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/uos20-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: uos20-x86_64
trying hardlink /var/www/cobbler/distro_mirror/uos20-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/uos20-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/uos20-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/uos20-x86_64/initrd.img
Writing template files for uos20-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
processing boot_files for distro: uos20-x86_64
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: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.servicerunning shell triggers from /var/lib/cobbler/triggers/sync/post/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***26.为避免发生未知问题,先把服务端所有服务重启
[root@cobbler ~]# systemctl restart httpd cobblerd
[root@cobbler ~]# systemctl status xinetd
● xinetd.service - Xinetd A Powerful Replacement For InetdLoaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled; vendor preset: enabled)Active: inactive (dead)Docs: man:xinetdman:xinetd.confman:xinetd.log
[root@cobbler ~]# systemctl enable --now xinetd
[root@cobbler ~]# systemctl status xinetd
● xinetd.service - Xinetd A Powerful Replacement For InetdLoaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled; vendor preset: enabled)Active: active (running) since Mon 2023-12-25 14:46:11 CST; 2s agoDocs: man:xinetdman:xinetd.confman:xinetd.logProcess: 274806 ExecStart=/usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid (code=exited, status=0/SUCCESS)Main PID: 274807 (xinetd)Tasks: 1Memory: 828.0KCGroup: /system.slice/xinetd.service└─274807 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
[root@cobbler ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 5 127.0.0.1:25151 0.0.0.0:*
LISTEN 0 5 0.0.0.0:873 0.0.0.0:*
LISTEN 0 511 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 511 *:443 *:*
LISTEN 0 5 [::]:873 [::]:*
3. 客户端安装(内存和cpu可以多个点,以免后面出错)
//解决方案
[root@cobbler ~]# cd /var/lib/tftpboot/
[root@cobbler tftpboot]# ls
boot COPYING.yaboot grub grub-x86_64.efi images menu.c32 pxelinux.0 README yaboot
COPYING.syslinux etc grub.cfg grub-x86.efi images2 ppc pxelinux.cfg s390x[root@cobbler ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.116.0 netmask 255.255.255.0 {option routers 192.168.116.146;option domain-name-servers 192.168.116.2;option subnet-mask 255.255.255.0;range dynamic-bootp 192.168.116.100 192.168.116.200;default-lease-time 21600;max-lease-time 43200;next-server $next_server;class "pxeclients" { //这里的其余的行可以删除吧filename这一行中的grup.0改为pxelinux.0match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";filename "pxelinux.0";}
}
//解决方案,不用同步
[root@cobbler ~]# cd /var/lib/tftpboot/
[root@cobbler tftpboot]# ls
boot COPYING.yaboot grub grub-x86_64.efi images menu.c32 pxelinux.0 README yaboot
COPYING.syslinux etc grub.cfg grub-x86.efi images2 ppc pxelinux.cfg s390x
[root@cobbler tftpboot]# mv menu.c32 pxelinux.0 /opt
[root@cobbler tftpboot]# ls /usr/share/syslinux
altmbr.bin cpuidtest.c32 gfxboot.c32 ifplop.c32 ldlinux.c32 mboot.c32 prdhcp.c32 syslinux.com
altmbr_c.bin debug.c32 gptmbr.bin isohdpfx.bin lfs.c32 mbr.bin pwd.c32 syslinux.exe
altmbr_f.bin dhcp.c32 gptmbr_c.bin isohdpfx_c.bin libcom32.c32 mbr_c.bin pxechn.c32 vesa.c32
cat.c32 diag gptmbr_f.bin isohdpfx_f.bin libgpl.c32 mbr_f.bin pxelinux.0 vesainfo.c32
chain.c32 dir.c32 gpxecmd.c32 isohdppx.bin liblua.c32 memdisk reboot.c32 vesamenu.c32
cmd.c32 disk.c32 hdt.c32 isohdppx_c.bin libmenu.c32 meminfo.c32 rosh.c32 vpdtest.c32
cmenu.c32 dmi.c32 hexdump.c32 isohdppx_f.bin libutil.c32 menu.c32 sanboot.c32 whichsys.c32
config.c32 dmitest.c32 host.c32 isolinux.bin linux.c32 pci.c32 sdi.c32 zzjson.c32
cptime.c32 dosutil ifcpu64.c32 isolinux-debug.bin lpxelinux.0 pcitest.c32 sysdump.c32
cpu.c32 elf.c32 ifcpu.c32 kbdmap.c32 ls.c32 pmload.c32 syslinux64.exe
cpuid.c32 ethersel.c32 ifmemdsk.c32 kontron_wdt.c32 lua.c32 poweroff.c32 syslinux.c32
[root@cobbler tftpboot]# cp /usr/share/syslinux/menu.c32 .
[root@cobbler tftpboot]# cp /usr/share/syslinux/pxelinux.0 .
[root@cobbler tftpboot]# ls
boot COPYING.yaboot grub grub-x86_64.efi images menu.c32 pxelinux.0 README yaboot
COPYING.syslinux etc grub.cfg grub-x86.efi images2 ppc pxelinux.cfg s390x
[root@cobbler tftpboot]# ll /usr/share/syslinux/menu.c32 /opt/menu.c32
-rw-r--r-- 1 root root 9379 12月 25 14:07 /opt/menu.c32
-rw-r--r-- 1 root root 26276 3月 15 2023 /usr/share/syslinux/menu.c32
[root@cobbler tftpboot]# ll /usr/share/syslinux/pxelinux.0 /opt/pxelinux.0
-rw-r--r-- 1 root root 9379 12月 25 14:07 /opt/pxelinux.0
-rw-r--r-- 1 root root 42373 3月 15 2023 /usr/share/syslinux/pxelinux.0
//解决方案
[root@cobbler tftpboot]# ls /usr/share/syslinux
altmbr.bin cpuidtest.c32 gfxboot.c32 ifplop.c32 ldlinux.c32 mboot.c32 prdhcp.c32 syslinux.com
altmbr_c.bin debug.c32 gptmbr.bin isohdpfx.bin lfs.c32 mbr.bin pwd.c32 syslinux.exe
altmbr_f.bin dhcp.c32 gptmbr_c.bin isohdpfx_c.bin libcom32.c32 mbr_c.bin pxechn.c32 vesa.c32
cat.c32 diag gptmbr_f.bin isohdpfx_f.bin libgpl.c32 mbr_f.bin pxelinux.0 vesainfo.c32
chain.c32 dir.c32 gpxecmd.c32 isohdppx.bin liblua.c32 memdisk reboot.c32 vesamenu.c32
cmd.c32 disk.c32 hdt.c32 isohdppx_c.bin libmenu.c32 meminfo.c32 rosh.c32 vpdtest.c32
cmenu.c32 dmi.c32 hexdump.c32 isohdppx_f.bin libutil.c32 menu.c32 sanboot.c32 whichsys.c32
config.c32 dmitest.c32 host.c32 isolinux.bin linux.c32 pci.c32 sdi.c32 zzjson.c32
cptime.c32 dosutil ifcpu64.c32 isolinux-debug.bin lpxelinux.0 pcitest.c32 sysdump.c32
cpu.c32 elf.c32 ifcpu.c32 kbdmap.c32 ls.c32 pmload.c32 syslinux64.exe
cpuid.c32 ethersel.c32 ifmemdsk.c32 kontron_wdt.c32 lua.c32 poweroff.c32 syslinux.c32
[root@cobbler tftpboot]# cp /usr/share/syslinux/ldlinux.c32 .
[root@cobbler tftpboot]# pwd
/var/lib/tftpboot
[root@cobbler tftpboot]# ls
boot COPYING.yaboot grub grub-x86_64.efi images ldlinux.c32 ppc pxelinux.cfg s390x
COPYING.syslinux etc grub.cfg grub-x86.efi images2 menu.c32 pxelinux.0 README yaboot
//解决方案
[root@cobbler tftpboot]# pwd
/var/lib/tftpboot
[root@cobbler tftpboot]# ls /usr/share/syslinux
altmbr.bin cpuidtest.c32 gfxboot.c32 ifplop.c32 ldlinux.c32 mboot.c32 prdhcp.c32 syslinux.com
altmbr_c.bin debug.c32 gptmbr.bin isohdpfx.bin lfs.c32 mbr.bin pwd.c32 syslinux.exe
altmbr_f.bin dhcp.c32 gptmbr_c.bin isohdpfx_c.bin libcom32.c32 mbr_c.bin pxechn.c32 vesa.c32
cat.c32 diag gptmbr_f.bin isohdpfx_f.bin libgpl.c32 mbr_f.bin pxelinux.0 vesainfo.c32
chain.c32 dir.c32 gpxecmd.c32 isohdppx.bin liblua.c32 memdisk reboot.c32 vesamenu.c32
cmd.c32 disk.c32 hdt.c32 isohdppx_c.bin libmenu.c32 meminfo.c32 rosh.c32 vpdtest.c32
cmenu.c32 dmi.c32 hexdump.c32 isohdppx_f.bin libutil.c32 menu.c32 sanboot.c32 whichsys.c32
config.c32 dmitest.c32 host.c32 isolinux.bin linux.c32 pci.c32 sdi.c32 zzjson.c32
cptime.c32 dosutil ifcpu64.c32 isolinux-debug.bin lpxelinux.0 pcitest.c32 sysdump.c32
cpu.c32 elf.c32 ifcpu.c32 kbdmap.c32 ls.c32 pmload.c32 syslinux64.exe
cpuid.c32 ethersel.c32 ifmemdsk.c32 kontron_wdt.c32 lua.c32 poweroff.c32 syslinux.c32
[root@cobbler tftpboot]# cp /usr/share/syslinux/libutil.c32 .
[root@cobbler tftpboot]# ls
boot COPYING.yaboot grub grub-x86_64.efi images ldlinux.c32 menu.c32 pxelinux.0 README yaboot
COPYING.syslinux etc grub.cfg grub-x86.efi images2 libutil.c32 ppc pxelinux.cfg s390x
新建虚拟机从pxe启动,若出现以下界面则表示成功:
//解决方案
[root@cobbler ~]# vim /var/lib/cobbler/templates/uos20.ks
[root@cobbler ~]# cat /var/lib/cobbler/templates/uos20.ks
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.116.146/cobbler/links/uos20-x86_64/
$yum_repo_stanza //删除这一行
rebootrootpw --iscrypted $6$WqdLuLnm2W8M98bv$XKfgxxCeviKNg4y/pj6bT2/b/WIT.91YyWcb3930BgVUiuHXuFtqQXLP3isSdfz2mZpSQCDqO.Ude3uL9pz370selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install //删除这一行
zerombr%packages
@^minimal //删除这一行
@core
kexec-tools%end%addon com_redhat_kdump --enable --reserve-mb='auto'%end%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
4.cobbler服务端部署centos7
接着上面的基础上部署
1.导入centos7镜像
[root@cobbler ~]# mount /dev/cdrom /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@cobbler ~]# ls /mnt
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL[root@cobbler ~]# cobbler import --path=/mnt --name=centos-7 --arch=x86_64
task started: 2023-12-25_153833_import
task started (id=Media import, time=Mon Dec 25 15:38:33 2023)
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=uniontech, version=uniontech
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
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/centos-7-x86_64:
creating new distro: centos-7-x86_64
trying symlink: /var/www/cobbler/distro_mirror/centos-7-x86_64 -> /var/www/cobbler/links/centos-7-x86_64
creating new profile: centos-7-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/centos-7-x86_64 for centos-7-x86_64
processing repo at : /var/www/cobbler/distro_mirror/centos-7-x86_64
need to process repo/comps: /var/www/cobbler/distro_mirror/centos-7-x86_64
looking for /var/www/cobbler/distro_mirror/centos-7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/centos-7-x86_64/repodata
*** TASK COMPLETE ***
2.查看cobbler镜像列表
[root@cobbler ~]# cobbler list
distros:centos-7-x86_64uos20-x86_64profiles:centos-7-x86_64uos20-x86_64systems:repos:images:mgmtclasses:packages:files:3.创建kickstarts自动安装脚本
[root@cobbler ~]# cd /var/lib/cobbler/templates/
[root@cobbler templates]# ls
default.ks install_profiles pxerescue.ks sample_esxi5.ks sample_legacy.ks uos20.ks
esxi4-ks.cfg legacy.ks sample_autoyast.xml sample_esxi6.ks sample_old.seed
esxi5-ks.cfg powerkvm.ks sample_esxi4.ks sample.ks sample.seed
[root@cobbler templates]# cp uos20.ks centos-7.ks
[root@cobbler templates]# ls
centos-7.ks esxi5-ks.cfg powerkvm.ks sample_esxi4.ks sample.ks sample.seed
default.ks install_profiles pxerescue.ks sample_esxi5.ks sample_legacy.ks uos20.ks
esxi4-ks.cfg legacy.ks sample_autoyast.xml sample_esxi6.ks sample_old.seed
[root@cobbler templates]# vim centos-7.ks
[root@cobbler templates]# cat centos-7.ks
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.116.146/cobbler/links/centos-7-x86_64/
$yum_repo_stanza
rebootrootpw --iscrypted $6$WqdLuLnm2W8M98bv$XKfgxxCeviKNg4y/pj6bT2/b/WIT.91YyWcb3930BgVUiuHXuFtqQXLP3isSdfz2mZpSQCDqO.Ude3uL9pz370selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr%packages
@^minimal
@core
kexec-tools%end%addon com_redhat_kdump --enable --reserve-mb='auto'%end%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end4.检查ks文件语法是否有误
[root@cobbler ~]# cobbler --help
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... [add|edit|copy|get-autoinstall*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validate-autoinstalls|version|signature|get-loaders|hardlink> [options|--help]
[root@cobbler ~]# cobbler validate-autoinstalls
task started: 2023-12-25_154550_validate_autoinstall_files
task started (id=Automated installation files validation, time=Mon Dec 25 15:45:50 2023)
running python triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
shell triggers finished successfully
*** TASK COMPLETE ***5.查看当前cobbler有哪些配置文件
[root@cobbler ~]# cobbler profile listcentos-7-x86_64uos20-x86_646.修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@cobbler ~]# cobbler profile edit --name centos-7-x86_64 --autoinstall=centos-7.ks7.配置网卡名称为传统网卡名称eth0
[root@cobbler ~]# cobbler profile edit --name centos-7-x86_64 --kernel-options='net.ifnames=0 biosdevname=0'8.检查当前系统cobbler配置文件信息
[root@cobbler ~]# cobbler profile report
Name : uos20-x86_64
Automatic Installation Template : uos20.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : uos20-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {'net.ifnames': '0', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<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 : kvmName : centos-7-x86_64
Automatic Installation Template : centos-7.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : centos-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {'net.ifnames': '0', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<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 : kvm9.为避免发生未知问题,先把服务端所有服务重启
[root@cobbler ~]# systemctl restart xinetd httpd cobblerd
[root@cobbler ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 5 0.0.0.0:873 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 5 127.0.0.1:25151 0.0.0.0:*
LISTEN 0 5 [::]:873 [::]:*
LISTEN 0 511 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 511 *:443 *:*
5.客户端安装
6.cobbler服务端部署centos8
1.导入centos8镜像
[root@cobbler ~]# mount /dev/cdrom /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@cobbler ~]# ls /mnt/
AppStream BaseOS EFI images isolinux LICENSE media.repo TRANS.TBL
[root@cobbler ~]# cobbler --help
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... [add|edit|copy|get-autoinstall*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validate-autoinstalls|version|signature|get-loaders|hardlink> [options|--help]
[root@cobbler ~]# cobbler signature update
task started: 2023-12-25_171337_sigupdate
task started (id=Updating Signatures, time=Mon Dec 25 17:13:37 2023)
running python triggers from /var/lib/cobbler/triggers/task/sigupdate/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sigupdate/pre/*
shell triggers finished successfully
Successfully got file from https://cobbler.github.io/signatures/3.0.x/latest.json
*** TASK COMPLETE ***
[root@cobbler ~]# cobbler import --path=/mnt --name=centos-8 --arch=x86_64
task started: 2023-12-25_210336_import
task started (id=Media import, time=Mon Dec 25 21:03:36 2023)
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/centos-8-x86_64:
creating new distro: centos-8-x86_64
trying symlink: /var/www/cobbler/distro_mirror/centos-8-x86_64 -> /var/www/cobbler/links/centos-8-x86_64
creating new profile: centos-8-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/centos-8-x86_64 for centos-8-x86_64
processing repo at : /var/www/cobbler/distro_mirror/centos-8-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/centos-8-x86_64/AppStream
looking for /var/www/cobbler/distro_mirror/centos-8-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/centos-8-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/centos-8-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/centos-8-x86_64/BaseOS
looking for /var/www/cobbler/distro_mirror/centos-8-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/centos-8-x86_64/BaseOS/repodata
*** TASK COMPLETE ***2.查看cobbler镜像列表
[root@cobbler ~]# cobbler list
distros:centos-7-x86_64centos-8-x86_64uos20-x86_64profiles:centos-7-x86_64centos-8-x86_64uos20-x86_64systems:repos:images:mgmtclasses:packages:files:3.创建kickstarts自动安装脚本
[root@cobbler ~]# cd /var/lib/cobbler/
[root@cobbler cobbler]# ls
collections distro_signatures.json grub_config loaders lock scripts snippets templates triggers web.ss webui_sessions
[root@cobbler cobbler]# cd templates/
[root@cobbler templates]# ls
centos-7.ks esxi4-ks.cfg install_profiles powerkvm.ks sample_autoyast.xml sample_esxi5.ks sample.ks sample_old.seed uos20.ks
default.ks esxi5-ks.cfg legacy.ks pxerescue.ks sample_esxi4.ks sample_esxi6.ks sample_legacy.ks sample.seed
[root@cobbler templates]# cp uos20.ks centos-8.ks
[root@cobbler templates]# vim centos-8.ks
[root@cobbler templates]# cat centos-8.ks
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.116.146/cobbler/links/centos-8-x86_64/
$yum_repo_stanza
rebootrootpw --iscrypted $6$WqdLuLnm2W8M98bv$XKfgxxCeviKNg4y/pj6bT2/b/WIT.91YyWcb3930BgVUiuHXuFtqQXLP3isSdfz2mZpSQCDqO.Ude3uL9pz370selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr%packages
@^minimal
@core
kexec-tools%end%addon com_redhat_kdump --enable --reserve-mb='auto'%end%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end4.检查ks文件语法是否有误
[root@cobbler ~]# cobbler --help
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... [add|edit|copy|get-autoinstall*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validate-autoinstalls|version|signature|get-loaders|hardlink> [options|--help]
[root@cobbler ~]# cobbler validate-autoinstalls
task started: 2023-12-25_172657_validate_autoinstall_files
task started (id=Automated installation files validation, time=Mon Dec 25 17:26:57 2023)
running python triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
shell triggers finished successfully
*** TASK COMPLETE ***5.查看当前cobbler有哪些配置文件
[root@cobbler ~]# cobbler profile listcentos-7-x86_64centos-8-x86_64uos20-x86_646.修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@cobbler ~]# cobbler profile edit --name centos-8-x86_64 --autoinstall=centos-8.ks7.配置网卡名称为传统网卡名称eth0
[root@cobbler ~]# cobbler profile edit --name centos-8-x86_64 --kernel-options='net.ifnames=0 biosdevname=0'8.检查当前系统cobbler配置文件信息
[root@cobbler ~]# cobbler profile report
Name : uos20-x86_64
Automatic Installation Template : uos20.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : uos20-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {'net.ifnames': '0', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<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 : kvmName : centos-7-x86_64
Automatic Installation Template : centos-7.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : centos-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {'net.ifnames': '0', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<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 : kvmName : centos-8-x86_64
Automatic Installation Template : centos-8.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : centos-8-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {'net.ifnames': '0', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<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
7.客户端安装
8.cobbler服务端部署rockylinux9
1.导入rockylinux9镜像
[root@cobbler ~]# mount /dev/cdrom /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@cobbler ~]# ls /mnt
AppStream BaseOS EFI images isolinux LICENSE media.repo
[root@cobbler ~]# cobbler --help
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... [add|edit|copy|get-autoinstall*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validate-autoinstalls|version|signature|get-loaders|hardlink> [options|--help]
[root@cobbler ~]# cobbler signature update
task started: 2023-12-25_173814_sigupdate
task started (id=Updating Signatures, time=Mon Dec 25 17:38:14 2023)
running python triggers from /var/lib/cobbler/triggers/task/sigupdate/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sigupdate/pre/*
shell triggers finished successfully
Successfully got file from https://cobbler.github.io/signatures/3.0.x/latest.json
*** TASK COMPLETE ***
[root@cobbler ~]# mount /dev/cdrom /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@cobbler ~]# cobbler signature update
task started: 2023-12-25_211938_sigupdate
task started (id=Updating Signatures, time=Mon Dec 25 21:19:38 2023)
running python triggers from /var/lib/cobbler/triggers/task/sigupdate/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sigupdate/pre/*
shell triggers finished successfully
Successfully got file from https://cobbler.github.io/signatures/3.0.x/latest.json
*** TASK COMPLETE ***
[root@cobbler ~]# cobbler import --path=/mnt --name=rockylinux9 --arch=x86_64
task started: 2023-12-25_212031_import
task started (id=Media import, time=Mon Dec 25 21:20:31 2023)
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 candidate signature: breed=redhat, version=rhel9
Found a matching signature: breed=redhat, version=rhel9
Adding distros from path /var/www/cobbler/distro_mirror/rockylinux9-x86_64:
creating new distro: rockylinux9-x86_64
trying symlink: /var/www/cobbler/distro_mirror/rockylinux9-x86_64 -> /var/www/cobbler/links/rockylinux9-x86_64
creating new profile: rockylinux9-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/rockylinux9-x86_64 for rockylinux9-x86_64
processing repo at : /var/www/cobbler/distro_mirror/rockylinux9-x86_64/AppStream
directory /var/www/cobbler/distro_mirror/rockylinux9-x86_64/AppStream is missing xml comps file, skipping
processing repo at : /var/www/cobbler/distro_mirror/rockylinux9-x86_64/BaseOS
directory /var/www/cobbler/distro_mirror/rockylinux9-x86_64/BaseOS is missing xml comps file, skipping
*** TASK COMPLETE ***2.查看cobbler镜像列表
[root@cobbler ~]# cobbler list
distros:centos-8-x86_64rockylinux9-x86_64uos20-x86_64profiles:centos-8-x86_64rockylinux9-x86_64uos20-x86_64systems:repos:images:mgmtclasses:packages:files:3.创建kickstarts自动安装脚本
[root@cobbler ~]# cd /var/lib/cobbler/templates/
[root@cobbler templates]# ls
centos-8.ks esxi4-ks.cfg install_profiles powerkvm.ks sample_autoyast.xml sample_esxi5.ks sample.ks sample_old.seed uos20.ks
default.ks esxi5-ks.cfg legacy.ks pxerescue.ks sample_esxi4.ks sample_esxi6.ks sample_legacy.ks sample.seed
[root@cobbler templates]# cp uos20.ks rockylinux9.ks
[root@cobbler templates]# vim rockylinux9.ks
[root@cobbler templates]# cat rockylinux9.ks
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.116.147/cobbler/links/rockylinux9-x86_64/
rebootrootpw --iscrypted $6$cbbyBQuKbE03l1D.$.0dMYU5cLAbG7w.wwLdJOreYDXusceBHnUUUHufkY25OZzF8mt7H7YzRWVYckC13uQB88ad09JQ93CsUabHJd0selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
zerombr%packages
@core
kexec-tools%end%addon com_redhat_kdump --enable --reserve-mb='auto'%end%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end4.检查ks文件语法是否有误
[root@cobbler ~]# cobbler --help
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... [add|edit|copy|get-autoinstall*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validate-autoinstalls|version|signature|get-loaders|hardlink> [options|--help]
[root@cobbler ~]# cobbler validate-autoinstalls
task started: 2023-12-25_212700_validate_autoinstall_files
task started (id=Automated installation files validation, time=Mon Dec 25 21:27:00 2023)
running python triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
shell triggers finished successfully
*** TASK COMPLETE ***5.查看当前cobbler有哪些配置文件
[root@cobbler ~]# cobbler profile listcentos-8-x86_64rockylinux9-x86_64uos20-x86_646.修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@cobbler ~]# cobbler profile edit --name rockylinux9-x86_64 --autoinstall=rockylinux9.ks7.配置网卡名称为传统网卡名称eth0
[root@cobbler ~]# cobbler profile edit --name rockylinux9-x86_64 --kernel-options='net.ifnames=0 biosdevname=0'8.检查当前系统cobbler配置文件信息
[root@cobbler ~]# cobbler profile report
Name : uos20-x86_64
Automatic Installation Template : uos20.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : uos20-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {'net.ifnames': '0', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<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 : kvmName : centos-8-x86_64
Automatic Installation Template : centos-8.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : centos-8-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {'net.ifnames': '0', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<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 : kvmName : rockylinux9-x86_64
Automatic Installation Template : rockylinux9.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : rockylinux9-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {'net.ifnames': '0', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<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
9.客户端安装
修改参数
1.第一个位置(这个位置可以忽略)
[root@cobbler ~]# cd /var/lib/tftpboot/
[root@cobbler tftpboot]# ls
boot COPYING.yaboot grub grub-x86_64.efi images ldlinux.c32 menu.c32 pxelinux.0 README yaboot
COPYING.syslinux etc grub.cfg grub-x86.efi images2 libutil.c32 ppc pxelinux.cfg s390x
[root@cobbler tftpboot]# ls grub
aarch64_menu_items.cfg arm_menu_items.cfg ia64_menu_items.cfg local_powerpc-ieee1275.cfg ppc64_menu_items.cfg system
amd64_menu_items.cfg grub.cfg images loongarch64_menu_items.cfg ppc_menu_items.cfg system_link
ARM64_menu_items.cfg i386_menu_items.cfg local_efi.cfg ppc64el_menu_items.cfg s390_menu_items.cfg x86_64_menu_items.cfg
armhfp_menu_items.cfg i586_menu_items.cfg local_legacy.cfg ppc64le_menu_items.cfg s390x_menu_items.cfg x86_menu_items.cfg
[root@cobbler tftpboot]# vim grub/x86_64_menu_items.cfg //找到rockylinux9的在ks前面加instappend initrd=/images/rockylinux9-x86_64/initrd.img net.ifnames=0 biosdevname=0 inst.kssendmac inst.ks=http://192.168.116.147/cblr/svc/op/autoinstall/profile/rockylinux9-x86_642.第二个位置
[root@cobbler tftpboot]# pwd
/var/lib/tftpboot
[root@cobbler tftpboot]# ls
boot COPYING.yaboot grub grub-x86_64.efi images ldlinux.c32 menu.c32 pxelinux.0 README yaboot
COPYING.syslinux etc grub.cfg grub-x86.efi images2 libutil.c32 ppc pxelinux.cfg s390x
[root@cobbler tftpboot]# ls pxelinux.cfg/
default
[root@cobbler tftpboot]# vim pxelinux.cfg/default
[root@cobbler tftpboot]# cat pxelinux.cfg/default //找到rockylinux9,ks前面加上instappend initrd=/images/rockylinux9-x86_64/initrd.img net.ifnames=0 biosdevname=0 inst.kssendmac inst.ks=http://192.168.116.147/cblr/svc/op/autoinstall/profile/rockylinux9-x86_643.第三个位置
[root@cobbler tftpboot]# find / -name tftp*.py
/usr/sbin/tftpd.py
/usr/lib/python3.6/site-packages/cobbler/modules/managers/tftpd_py.py
/usr/lib/python3.6/site-packages/cobbler/tftpgen.py
[root@cobbler tftpboot]# ls /usr/lib/python3.6/site-packages/cobbler
actions cexceptions.py cobblerd.py grub.py modules resource.py templar.py validate.py
api.py cli.py configgen.py __init__.py power_manager.py serializer.py template_api.py web
autoinstallgen.py clogger.py download_manager.py items __pycache__ services.py tftpgen.py yumgen.py
autoinstall_manager.py cobbler_collections field_info.py module_loader.py remote.py settings.py utils.py
//用/sendmac找,然后在ks前面加上inst
[root@cobbler tftpboot]# vim /usr/lib/python3.6/site-packages/cobbler/tftpgen.py append_line += " inst.kssendmac"append_line = "%s inst.ks=%s" % (append_line, autoinstall_path)gpxe = blended["enable_gpxe"]
10.定制安装
定制安装步骤:
- 统计服务器mac地址
- 配置cobbler
- 安装
统计mac地址此处就不赘述了,直接最重要的配置
在 cobbler 的web界面上配置: