cobbler自动安装centos{7,8}
1,安装cobbler以及相关服务,安装cobbler需要epel源
[root@localhost yum.repos.d]#yum install cobbler dhcp -y
[root@localhost yum.repos.d]#systemctl enable --now cobblerd httpd tftp dhcpd
[root@localhost yum.repos.d]# cat /etc/yum.repos.d/tence.repo
[tt]
name=11
baseurl=https://mirrors.cloud.tencent.com/epel/7/x86_64/
enabled=1
gpgcheck=0
2,修改配置
[root@localhost yum.repos.d]#openssl passwd -1 '123' #生成加密密码
$1$1spuisnh$j34LNmyTQWs3l6xKxCZY60
#根据以上提示,只需要做1,2,8这三项即可,修改下面四行
[root@localhost yum.repos.d]#vim /etc/cobbler/settings
default_password_crypted: "$1$1spuisnh$j34LNmyTQWs3l6xKxCZY60"
next_server:< tftp服务器的 IP 地址> #本机
server:<cobbler服务器的 IP 地址> #本机
manage_dhcp:1 #设置为1,表示通过cobbler生成dhcpd.conf配置文件
3,修改DHCP模板文件
#修改dhcp的模版文件下面的行,用来生成dhcp的配置文件
[root@localhost yum.repos.d]#vim /etc/cobbler/dhcp.template
#你的网段
subnet 192.168.100.0 netmask 255.255.255.0 {
#网关
option routers 192.168.100.1;
#域名服务器
option domain-name-servers 180.76.76.76,223.6.6.6;
#掩码
option subnet-mask 255.255.255.0;
#分配网段
range dynamic-bootp 192.168.100.1 192.168.100.200;
[root@localhost yum.repos.d]#cobbler sync
[root@localhost yum.repos.d]#systemctl start dhcpd #可查看dhcp配置文件验证
4,下载启动文件
[root@localhost yum.repos.d]# cobbler get-loaders --force
task started: 2021-05-20_234359_get_loaders
task started (id=Download Bootloader Content, time=Thu May 20 23:43:59 2021)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
Exception occured: <class 'urlgrabber.grabber.URLGrabError'>
Exception value: [Errno 14] curl#60 - "Issuer certificate is invalid."
Exception Info:
File "/usr/lib/python2.7/site-packages/cobbler/remote.py", line 82, in run
rc = self._run(self)
File "/usr/lib/python2.7/site-packages/cobbler/remote.py", line 176, in runner
return self.remote.api.dlcontent(self.options.get("force",False), self.logger)
File "/usr/lib/python2.7/site-packages/cobbler/api.py", line 735, in dlcontent
#报错,执行下列操作
#网上查的依然报错
[root@localhost yum.repos.d]# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
[root@localhost yum.repos.d]# cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
[root@localhost yum.repos.d]# systemctl restart cobblerd
[root@localhost yum.repos.d]# cobbler check #没办法做check 根据报错提示安装了以下包
[root@localhost yum.repos.d]# yum install -y rsync;systemctl enable --now rsyncd
[root@localhost yum.repos.d]#yum install -y fence-agents
[root@localhost yum.repos.d]# yum install -y debmirror
[root@localhost ~]# vim /etc/debmirror.conf #注释了一些信息
#@dists="sid";
@sections="main,main/debian-installer,contrib,non-free";
#@arches="i386";
#下是报错提示
The following are potential configuration items that you may want to fix:
1 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, 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, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
2 : comment out 'dists' on /etc/debmirror.conf for proper debian support
3 : comment out 'arches' on /etc/debmirror.conf for proper debian support
#做完上述操作后
[root@localhost ~]#systemctl restart cobblerd
[root@localhost ~]#scobbler get-loaders
[root@localhost yum.repos.d]# cobbler get-loaders
task started: 2021-05-21_002101_get_loaders
task started (id=Download Bootloader Content, time=Fri May 21 00:21:01 2021)
path /var/lib/cobbler/loaders/README already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/COPYING.elilo already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/COPYING.yaboot already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/COPYING.syslinux already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/elilo-ia64.efi already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/yaboot already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/pxelinux.0 already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/menu.c32 already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/grub-x86.efi already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/grub-x86_64.efi already exists, not overwriting existing content, use --force if you wish to update
*** TASK COMPLETE ***
5,同步后查看启动文件是否完整
[root@centos7 ~]#cobbler sync
[root@localhost yum.repos.d]# tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── boot
│ └── grub
│ └── menu.lst
├── etc
├── grub
│ ├── efidefault
│ ├── grub-x86_64.efi
│ ├── grub-x86.efi
│ └── images -> ../images
├── images
├── images2
├── memdisk
├── menu.c32
├── ppc
├── pxelinux.0
├── pxelinux.cfg
│ └── default
├── s390x
│ └── profile_list
└── yaboot
10 directories, 10 files
6,修改模板信息
[root@localhost yum.repos.d]# vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | http://123.com/
[root@localhost yum.repos.d]# cobbler sync
7,导入CentOS系统的安装文件,生成相应的YUM源
[root@localhost yum.repos.d]# mount /dev/sr0 /mnt/c7/
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost yum.repos.d]# mount /dev/sr1 /mnt/c8/
mount: /dev/sr1 is write-protected, mounting read-only
[root@localhost yum.repos.d]# ll !$
ll /mnt/c8/
total 12
dr-xr-xr-x 4 root root 2048 Jan 4 2020 AppStream
dr-xr-xr-x 4 root root 2048 Jan 4 2020 BaseOS
dr-xr-xr-x 3 root root 2048 Jan 4 2020 EFI
dr-xr-xr-x 3 root root 2048 Jan 4 2020 images
dr-xr-xr-x 2 root root 2048 Jan 4 2020 isolinux
-r--r--r-- 1 root root 87 Jan 4 2020 media.repo
-r--r--r-- 1 root root 664 Jan 4 2020 TRANS.TBL
[root@localhost yum.repos.d]# ll /mnt/c7/
total 686
-rw-rw-r-- 1 root root 14 Nov 26 2018 CentOS_BuildTag
drwxr-xr-x 3 root root 2048 Nov 26 2018 EFI
-rw-rw-r-- 1 root root 227 Aug 30 2017 EULA
-rw-rw-r-- 1 root root 18009 Dec 10 2015 GPL
drwxr-xr-x 3 root root 2048 Nov 26 2018 images
drwxr-xr-x 2 root root 2048 Nov 26 2018 isolinux
drwxr-xr-x 2 root root 2048 Nov 26 2018 LiveOS
drwxrwxr-x 2 root root 663552 Nov 26 2018 Packages
drwxrwxr-x 2 root root 4096 Nov 26 2018 repodata
-rw-rw-r-- 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 root root 2883 Nov 26 2018 TRANS.TBL
#生成cobbler镜像
[root@localhost yum.repos.d]# cobbler import --name=centos-8.1-x86_64 --path=/mnt/c8/ --arch=x86_64 #centos7,8大概需要十多个g注意保持磁盘空间充裕
[root@localhost yum.repos.d]# cobbler import --name=centos-7.7-x86_64 --path=/mnt/c7/ -- arch=x86_64 #结尾*** TASK COMPLETE ***
[root@localhost ~]# du -sh /var/www/cobbler/ks_mirror/*
4.3G /var/www/cobbler/ks_mirror/centos-7.7-x86_64
7.2G /var/www/cobbler/ks_mirror/centos-8.1-x86_64
12K /var/www/cobbler/ks_mirror/config
[root@localhost ~]# cobbler distro list
centos-7.7-x86_64
centos-8.1-x86_64
[root@localhost ~]# cobbler profile list
centos-7.7-x86_64
centos-8.1-x86_64
[root@localhost ~]#
8,准备 kickstart文件,并关联至指定的YUM源,kickstart的文件建议用生成之前的镜像安装后的anaconda-ks.cfg 不然可能会报错,这里只准备centos7,url配置:url --url=$tree
root@localhost ~]# vim /var/lib/cobbler/kickstarts/centos7.cfg
[root@localhost ~]#
[root@localhost ~]# cat /var/lib/cobbler/kickstarts/centos7.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$t206J5fU$oTe6HgUIUWLVNQIpCBt8b/
# System language
lang zh_CN
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use network installation
url --url=$tree
# Use graphical install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --ipv6=auto --activate
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part swap --fstype="swap" --ondisk=sda --size=2049
part / --fstype="xfs" --ondisk=sda --size=40240
part /boot --fstype="xfs" --ondisk=sda --size=1024
%packages
@^minimal
@compat-libraries
@core
@debugging
@development
@security-tools
@smart-card
@system-admin-tools
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
#将kickstart文件,关联指定的YUM源和生成菜单列表
[root@localhost ~]# cobbler profile add --name=CentOS-7.1_test --distro=CentOS-7.1-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg
[root@localhost ~]# cobbler profile add --name=CentOS-7.1_test --distro=CentOS-7.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg
[root@localhost ~]# cobbler profile remove --name=centos-7.7-x86_64
[root@localhost ~]# cobbler profile remove --name=centos-8.1-x86_64
[root@localhost ~]# cobbler profile list
CentOS-7.1_test
CentOS-8.1_test
9,同步,重启,查看报告
[root@localhost ~]# cobbler sync
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler report
10,测试



浙公网安备 33010602011771号