Rocky部署Cobbler

1、安装软件

cobbler版本3.3.3  rockyliux9.2

[root@wenzi ~]#dnf -y install cobbler dhcp-server
[root@wenzi ~]#systemctl enable --now cobblerd tftp.service httpd dhcpd

2、配置cobbler

cobbler配置检查

[root@wenzi ~]#cobbler check
The following are potential configuration items that you may want to fix:

1: The 'server' field in /etc/cobbler/settings.yaml must be set to something other than localhost, or automatic installation 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_v4' field in /etc/cobbler/settings.yaml 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: For PXE to be functional, the 'next_server_v6' field in /etc/cobbler/settings.yaml must be set to something other than ::1, and should match the IP of the boot server on the PXE network.
4: some network boot-loaders are missing from /var/lib/cobbler/loaders. 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, andmenu.c32.
5: reposync is not installed, install yum-utils or dnf-plugins-core
6: yumdownloader is not installed, install yum-utils or dnf-plugins-core
7: debmirror package is not installed, it will be required to manage debian deployments and repositories
8: ksvalidator was not found, install pykickstart
9: The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings.yaml) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
10: 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.

根据check结果提示安装相关包

[root@wenzi ~]#dnf -y install syslinux dnf-plugins-core pykickstart
#使用md5加密生成密码,用于下面cobbler配置文件
[root@wenzi ~]#openssl passwd -1
Password:
Verifying - Password:
$1$L9q17zY8$VGlrtSiCN5IkRnqkpEB/o1

修改cobbler主配置文件 

[root@wenzi ~]#vim /etc/cobbler/settings.yaml
...
#新装系统的root密码
default_password_crypted: "$1$L9q17zY8$VGlrtSiCN5IkRnqkpEB/o1"
...
#使用cobbler管理dhcp
manage_dhcp: true
...
manage_dhcp_v4: true
...
#tftp地址
next_server_v4: 192.168.28.128
...
#cobbler服务器地址
server: 192.168.28.128
...
#使用cobbler管理tftp
manage_tftpd: true
...
#当bios首选启动项是pxe时,此项设置为true,可避免重启反复安装系统,否则为false
pxe_just_once: true
...

修改dhcp模版文件

[root@wenzi ~]#vim /etc/cobbler/dhcp.template
...
subnet 192.168.28.0 netmask 255.255.255.0 {
     option routers             192.168.28.2;
     option domain-name-servers 223.5.5.5,180.76.76.76;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.28.130 192.168.28.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server_v4;
...

重启cobblerd、dhcpd、tftp.service、httpd;cobbler同步配置

[root@wenzi ~]#systemctl restart cobblerd httpd tftp.service dhcpd
[root@wenzi ~]#cobbler sync

修改启动菜单模版

菜单标题为:Wenzi Cobbler Menu。

[root@wenzi ~]#vim /etc/cobbler/boot_loader_conf/pxe_menu.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | Wenzi Cobbler Menu
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        KERNEL chain.c32
        APPEND hd0 0

导入系统镜像资源

centos6/7/8;镜像资源存放在 /var/www/cobbler/distro_mirror/

[root@wenzi ~]#lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sr0              11:0    1  3.6G  0 rom  /mnt/centos6
sr1              11:1    1  1.5G  0 rom
sr2              11:2    1  4.4G  0 rom  /mnt/centos7
sr3              11:3    1  7.7G  0 rom  /mnt/centos8
nvme0n1         259:0    0   40G  0 disk
├─nvme0n1p1     259:1    0    1G  0 part /boot
└─nvme0n1p2     259:2    0   39G  0 part
  ├─rl_192-root 253:0    0 35.1G  0 lvm  /
  └─rl_192-swap 253:1    0  3.9G  0 lvm  [SWAP]
nvme0n2         259:3    0   20G  0 disk
[root@wenzi ~]#cobbler import --name=centos-6.8-x86_64 --path=/mnt/centos6 --arch=x86_64
[root@wenzi ~]#cobbler import --name=centos-7.9-x86_64 --path=/mnt/centos7 --arch=x86_64
[root@wenzi ~]#cobbler import --name=centos-8.2-x86_64 --path=/mnt/centos8 --arch=x86_64
[root@wenzi ~]#ls /var/www/cobbler/distro_mirror/
centos-6.8-x86_64  centos-7.9-x86_64  centos-8.2-x86_64  config
[root@wenzi ~]#cobbler distro list
   centos-6.8-x86_64
   centos-7.9-x86_64
   centos-8.2-x86_64
[root@wenzi ~]#cobbler profile list
   centos-6.8-x86_64
   centos-7.9-x86_64
   centos-8.2-x86_64

重启cobbler,同步配置。查看生成的启动菜单

[root@wenzi ~]#systemctl restart  cobblerd
[root@wenzi ~]#cobbler sync
[root@wenzi ~]#vim /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | Wenzi Cobbler Menu
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

LABEL centos-6.8-x86_64
        MENU LABEL centos-6.8-x86_64
        kernel /images/centos-6.8-x86_64/vmlinuz
        append initrd=/images/centos-6.8-x86_64/initrd.img  kssendmac inst.ks=http://192.168.28.128/cblr/svc/op/autoinstall/profile/centos-6.8-x86_64
        ipappend 2
LABEL centos-7.9-x86_64
        MENU LABEL centos-7.9-x86_64
        kernel /images/centos-7.9-x86_64/vmlinuz
        append initrd=/images/centos-7.9-x86_64/initrd.img  kssendmac inst.ks=http://192.168.28.128/cblr/svc/op/autoinstall/profile/centos-7.9-x86_64
        ipappend 2
LABEL centos-8.2-x86_64
        MENU LABEL centos-8.2-x86_64
        kernel /images/centos-8.2-x86_64/vmlinuz
        append initrd=/images/centos-8.2-x86_64/initrd.img  kssendmac inst.ks=http://192.168.28.128/cblr/svc/op/autoinstall/profile/centos-8.2-x86_64
        ipappend 2
MENU end

生成引导加载程序 cobbler mkloaders 此命令适用cobblerV3.3.1及之后的版本。

此命令不执行的话新建虚拟机(无cd/dvd)开机会提示pxe-T01:file not found

[root@wenzi ~]#cobbler mkloaders
[root@wenzi ~]#ls /var/lib/cobbler/loaders/
grub  ldlinux.c32  libutil.c32  memdisk  menu.c32  pxelinux.0

自定义kickstart文件

centos6

root密码admin.

install
text
reboot
url --url=$tree
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$OYCRKMSDIK6mn9VG$jul4P1wBUGqDzj9ZWOi.KLoadka.qlhvUMP1L88RCf96SQp91BVG/kcj34U6toB2PZRcXcWzyF2NYIFSmYeY31
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="nomodeset crashkernel=auto rhgb quiet"
zerombr
clearpart --all --initlabel
part /boot --fstype="ext4" --ondisk=sda --size=1024
part /swap --fstype="swap" --ondisk=sda --size=2048
part / --fstype="ext4" --ondisk=sda --grow --size=1


%packages
@chinese-support
@core
@server-policy
@workstation-policy

%end

%post
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/* /etc/yum.repos.d/backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
yum makecache
yum -y install vim

%end

centos7

#version=DEVEL
install
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
# Use graphical install
text
url --url=$tree
# Run the Setup Agent on first boot
firstboot --enable
selinux --disabled
firewall --disabled
skipx
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=ens33 --ipv6=auto --activate
network  --hostname=wenzi.localhost
reboot
# Root password
rootpw --iscrypted $6$h9zNLvxii9Zkts/H$Mv8n6MBuLk0HLD1arRA0A/T38ZMpeU0DYLKkdFSYlWG3A3LE7lVhydaLQqSRlxpu9cq6qJ7FPZ5.14WHS4kOv1
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --ondisk=sda --size=1024
part /swap --fstype="swap" --ondisk=sda --size=2048
part / --fstype="xfs" --ondisk=sda --grow --size=1

%packages
@^minimal
@core
chrony
kexec-tools

%end

%post
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/* /etc/yum.repos.d/backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum -y install vim


%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

centos8

#version=RHEL8
install
ignoredisk --only-use=sda
# Partition clearing information
clearpart --all --initlabel
# Use graphical install
text
# Use CDROM installation media
url --url=$tree

reboot
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang en_US.UTF-8

selinux --disabled
firewall --disabled
# Network information
network  --bootproto=dhcp --device=ens160 --ipv6=auto --activate
network  --hostname=wenzi.localhost
# Root password
rootpw --iscrypted $6$IdPDEApucOtJWpXv$0VvvGoESO82WtIutqgKaViQPEiFLzd9sjXZqZwUhxRsuLR.7bVA6CSiCiaIvnR.QE4KSeKYZU.UeM0h8TtUes1
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# Disk partitioning information
zerombr

part /boot --fstype="ext4" --ondisk=sda --size=1024
part /swap --fstype="swap" --ondisk=sda --size=2048
part / --fstype="xfs" --ondisk=sda --grow --size=1


%packages
@^minimal-environment
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%post
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/* /etc/yum.repos.d/backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum makecache
yum -y install vim


%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

更新启动菜单

[root@wenzi ~]#cobbler profile remove --name=centos-6.8-x86_64
[root@wenzi ~]#cobbler profile remove --name=centos-7.9-x86_64
[root@wenzi ~]#cobbler profile remove --name=centos-8.2-x86_64
[root@wenzi ~]#cobbler profile add --name=centos-6.8-x86_64 --distro=centos-6.8-x86_64 --autoinstall=centos6.ks
[root@wenzi ~]#cobbler profile add --name=centos-7.9-x86_64 --distro=centos-7.9-x86_64  --autoinstall=centos7.ks
[root@wenzi ~]#cobbler profile add --name=centos-8.2-x86_64 --distro=centos-8.2-x86_64  --autoinstall=centos8.ks
[root@wenzi ~]#systemctl restart cobblerd
[root@wenzi ~]#cobbler sync

测试

测试出现问题,后查询许久发现已经有人在github上反馈了该bug,暂未修复

https://github.com/cobbler/cobbler/issues/3417

Rocky部署Cobbler_第1张图片

Rocky部署Cobbler_第2张图片

你可能感兴趣的:(Rocky,Linux9.2,linux,运维)