cobbler位于EPEL源中再次不在贅述
[root@localhost ~]# yum install cobbler dhcp -y
[root@localhost ~]# systemctl enable --now cobblerd httpd tftp dhcpd
cobbler類似于指引的一個(gè)檢查項(xiàng)
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting 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' field in /etc/cobbler/settings 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 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : 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.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : ksvalidator was not found, install pykickstart
8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
9 : 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.
大意為:
1:“/etc/cobbler/settings”中的“server”字段必須設(shè)置為localhost以外的內(nèi)容,否則啟動(dòng)特性將不起作用。這應(yīng)該是引導(dǎo)服務(wù)器的可解析主機(jī)名或IP,所有將使用它的機(jī)器都可以訪問它。
2:為了使PXE正常運(yùn)行,“/etc/cobbler/settings”中的“next_server”字段必須設(shè)置為127.0.0.1以外的值,并且要與PXE網(wǎng)絡(luò)中的引導(dǎo)服務(wù)器的IP匹配。
3:修改/etc/xinetd.d/tftp文件中的disable為no
4: /var/lib/cobbler/loaders中缺少一些網(wǎng)絡(luò)引導(dǎo)加載程序,你可以運(yùn)行'cobbler get-loaders'下載它們,或者,如果你只想處理x86/x86_64的網(wǎng)絡(luò)引導(dǎo),你可以確保你已經(jīng)安裝了一個(gè)最新版本的syslinux包,可以完全忽略這個(gè)消息。如果希望支持所有架構(gòu),該目錄中的文件應(yīng)該包括pxelinux。0,菜單。c32 elilo。efi, yaboot。“cobbler get-loader”命令是解決這些需求的最簡(jiǎn)單方法。
5:啟用并啟動(dòng)rsyncd。服務(wù)與systemctl
6:沒有安裝debmirror包,需要它來管理debian部署和存儲(chǔ)庫沒有找到ksvalidator,請(qǐng)安裝pykickstart
8:新安裝的機(jī)器(在/etc/cobbler/settings中的default_password_crypted)的樣例模板使用的默認(rèn)密碼仍然設(shè)置為cobbler,需要更改,嘗試:"openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'"來生成新的密碼
9:沒有發(fā)現(xiàn)fencing工具,需要使用(可選)power management特性。安裝cman或fence-agent來使用它們重新啟動(dòng)cobblerd,然后運(yùn)行“cobbler sync”應(yīng)用更改。
生成新的密鑰
[root@localhost ~]# openssl passwd -1 'ptg123'
$1$vaTFBiUq$BGihSVEeNSn6Jpcd6AcDl0
修改配置文件,并重啟cobbler服務(wù)
[root@localhost ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$vaTFBiUq$BGihSVEeNSn6Jpcd6AcDl0"
next_server: 192.168.1.253
server: 192.168.1.253
manage_dhcp: 1
[root@localhost ~]# systemctl restart cobblerd
使用cobbler創(chuàng)建DHCP文件
[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.253;
option domain-name-servers 223.6.6.6;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.1 192.168.1.100;
next-server $next_server;
[root@localhost ~]# cobbler sync
task started: 2021-03-21_111019_sync
task started (id=Sync, time=Sun Mar 21 11:10:19 2021)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
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.service
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
下載啟動(dòng)相關(guān)的配置文件
[root@localhost ~]# cobbler get-loaders
task started: 2021-03-21_120038_get_loaders
task started (id=Download Bootloader Content, time=Sun Mar 21 12:00:38 2021)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
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/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
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 ***
查看下載的文件,并執(zhí)行同步操作
[root@localhost ~]# tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── boot
│ └── grub
│ └── menu.lst
├── etc
├── grub
│ ├── efidefault
│ └── images -> ../images
├── images
├── images2
├── memdisk
├── menu.c32
├── ppc
├── pxelinux.0
├── pxelinux.cfg
│ └── default
└── s390x
└── profile_list
10 directories, 7 files
[root@localhost ~]# cobbler sync
task started: 2021-03-21_120415_sync
task started (id=Sync, time=Sun Mar 21 12:04:15 2021)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
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.service
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
定制標(biāo)題信息
[root@localhost ~]# vim /etc/cobbler/pxe/pxedefault.template
[root@localhost ~]# cobbler sync
task started: 2021-03-21_120614_sync
task started (id=Sync, time=Sun Mar 21 12:06:14 2021)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
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.service
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
[root@localhost ~]# cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://ptg123.com
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
MENU end
導(dǎo)入centos7的鏡像源
[root@localhost ~]# mkdir /mnt/centos7
[root@localhost ~]# mount /dev/cdrom /mnt/centos7
[root@localhost ~]# cobbler import --name=centos-7.7-x86_64 --path=/mnt/centos7 --arch=x86_64
task started: 2021-03-21_125603_import
task started (id=Media import, time=Sun Mar 21 12:56:03 2021)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/centos-7.7-x86_64:
creating new distro: centos-7.7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos-7.7-x86_64 -> /var/www/cobbler/links/centos-7.7-x86_64
creating new profile: centos-7.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/ks_mirror/centos-7.7-x86_64 for centos-7.7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos-7.7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos-7.7-x86_64
looking for /var/www/cobbler/ks_mirror/centos-7.7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos-7.7-x86_64/repodata
*** TASK COMPLETE ***
[root@localhost ~]# cobbler distro list
centos-7.7-x86_64
創(chuàng)建kickstart文件,并添加進(jìn)菜單中
[root@localhost ~]# cat /var/lib/cobbler/kickstarts/centos7.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url=$tree
# Use graphical install
text
# 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 --onboot=on --ipv6=auto --activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$0U7I.uZWqQ4DZrp1$T/L3volXctFcFO8h7s9d/J/fXl2jjdIOUf6qaFYUarwiC2.yBD79rYFWTVZ5s2SIsIIr7lkroxs7deZNO6znn/
# System services
services --disabled="chronyd"
selinux --disabled
firewall --disabled
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# X Window System configuration information
xconfig --startxonboot
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel
zerombr
eula --agreed
reboot
# Disk partitioning information
part swap --fstype="swap" --ondisk=sda --size=3072
part / --fstype="xfs" --ondisk=sda --size=51200
part /boot --fstype="xfs" --ondisk=sda --size=1024
part /data --fstype="xfs" --ondisk=sda --size=30720
%packages
@core
autofs
%end
%post
systemctl enable autofs
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=file:///misc/cd/
gpgcheck=0
EOF
useradd ptg
echo magedu |passwd --stdin ptg123
mkdir /root/.ssh
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSV0vkgeRJPikUdZ6V/RV6sLwGfw1LfapEFh8wxgYcS4tY9txVzpzJzTWuCmqMLZDK3AQt4AHOK7H39OAgIECr79wmzh1kHDj/i6asSw9Z9Nf+R4QlLhwWEfWV1nuk/SgxTLgQlqFh/9NGjG+gyihhCqfq2xHWcOyuf/pLH/IsfRP26MdP2o0YC4copRJVBPf/eO0lR+VbthDsm2yoYXuCYXur9423MNd5zV0hO+EcEiasDXsA3xPz8NwUVWumekYyIttnTRoCYsDuZPA6B0hp3Uh0krwgbGXqnc+uW7tbOveFDpkC9gXHUitt8MqemSx7i+DX3orO3J6f6b4C5gM7 root@centos7.localdomain' > /root/.ssh/authorized_keys
echo 'alias cdnet="cd /etc/sysconfig/network-scripts"' >> /root/.bashrc
%end
[root@localhost ~]# cobbler profile add --name=CentOS-7.7_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 list
CentOS-7.7_test
