欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CentOS 7基于cobbler实现系统的自动化安装

程序员文章站 2022-06-21 18:57:02
...

1 环境准备

两台主机
一台主机:CentOS 7充当Cobbler,http,dhcp,tftp服务器,并关闭防火墙和SELinux
一台主机:充当测试机,用于实现自动化安装Linux系统
网络要求:关闭Vmware软件中的NAT模式中的DHCP服务,两个主机网卡基于NAT模式

2 安装相关包并启动服务

[aaa@qq.com ~]# yum -y install cobbler dhcp
[aaa@qq.com ~]# systemctl enable --now cobblered httpd tftp dhcpd

3 修改cobbler相关的配置

[aaa@qq.com ~]# 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.

#生成新密码,默认安装好的系统root密码为cobbler
[aaa@qq.com ~]# openssl passwd -1 "centos"
$1$9vZJIjET$U4BI/SLRSPqs5a71tZ.lh1

#根据以上提示,只需做1,2,8这三项即可,修改下面四行
[aaa@qq.com ~]#vim /etc/cobbler/settings
default_password_crypted: "$1$9vZJIjET$U4BI/SLRSPqs5a71tZ.lh1"
next_server: 10.0.0.7		#tftp服务器的地址
server: 10.0.0.7			#cobbler服务器的地址
manage_dhcp: 1		#设置为1,表示通过cobbler生成dhcp.conf配置文件

[aaa@qq.com ~]# systemctl restart cobblerd

4 实现dhcp服务

#修改dhcp的模板文件下面的行,用来生成dhcp的配置文件
[aaa@qq.com ~]#vim /etc/cobbler/dhcp.template
subnet 10.0.0.0 netmask 255.255.255.0 {
     option routers             10.0.0.2;
     option domain-name-servers 180.76.76.76,223.5.5.5;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        10.0.0.50 10.0.0.100;

[aaa@qq.com ~]# cobbler sync
task started: 2020-09-09_214154_sync
task started (id=Sync, time=Wed Sep  9 21:41:54 2020)
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
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 ***
[aaa@qq.com ~]# systemctl start dhcpd

5 下载启动的相关文件

[aaa@qq.com ~]# cobbler get-loaders
task started: 2020-09-09_214411_get_loaders
task started (id=Download Bootloader Content, time=Wed Sep  9 21:44:11 2020)
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 ***
[aaa@qq.com ~]# ls /var/lib/cobbler/loaders/
COPYING.elilo     COPYING.yaboot  grub-x86_64.efi  menu.c32    README
COPYING.syslinux  elilo-ia64.efi  grub-x86.efi     pxelinux.0  yaboot
[aaa@qq.com ~]# 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
[aaa@qq.com ~]# cobbler sync
task started: 2020-09-09_214658_sync
task started (id=Sync, time=Wed Sep  9 21:46:58 2020)
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 ***

[aaa@qq.com ~]# 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 修改菜单的标题信息(可选)

[aaa@qq.com ~]# vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | http://www.kingdom_24.com/

[aaa@qq.com ~]# cobbler sync
[aaa@qq.com ~]# cat /var/lib/tftpboot/pxelinux.cfg/default 
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://www.kingdom_24.com/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

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



MENU end

[aaa@qq.com ~]# cobbler sync

7 导入CentOS系统的安装文件,生成相应的YUM源

[aaa@qq.com ~]# yum -y install autofs
[aaa@qq.com ~]# systemctl enable --now autofs
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.
[aaa@qq.com ~]# ls /misc/cd
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL
#提前挂载好centos 6 7和8的镜像文件
[aaa@qq.com ~]# yum -y install autofs
[aaa@qq.com ~]# systemctl enable --now autofs
[aaa@qq.com ~]# ls /misc/cd
AppStream  BaseOS  EFI  images  isolinux  media.repo  TRANS.TBL
[aaa@qq.com ~]# cobbler import --name=centos-8.0-x86_64 --path=/misc/cd --arch=x86_64
task started: 2020-09-12_104926_import
task started (id=Media import, time=Sat Sep 12 10:49:26 2020)
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/ks_mirror/centos-8.0-x86_64:
creating new distro: centos-8.0-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos-8.0-x86_64 -> /var/www/cobbler/links/centos-8.0-x86_64
creating new profile: centos-8.0-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-8.0-x86_64 for centos-8.0-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos-8.0-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/ks_mirror/centos-8.0-x86_64/AppStream
looking for /var/www/cobbler/ks_mirror/centos-8.0-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos-8.0-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/ks_mirror/centos-8.0-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/ks_mirror/centos-8.0-x86_64/BaseOS
looking for /var/www/cobbler/ks_mirror/centos-8.0-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos-8.0-x86_64/BaseOS/repodata
*** TASK COMPLETE ***
[aaa@qq.com ~]# mkdir /mnt/centos{6,7}
[aaa@qq.com ~]# mount /dev/sr1 /mnt/centos7
[aaa@qq.com ~]# mount CentOS-6.10-x86_64-minimal.iso /mnt/centos6
[aaa@qq.com ~]# cobbler import --name=centos-7.8-x86_64 --path=/mnt --arch=x86_64
task started: 2020-09-12_105729_import
task started (id=Media import, time=Sat Sep 12 10:57:29 2020)
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.8-x86_64:
creating new distro: centos-7.8-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos-7.8-x86_64 -> /var/www/cobbler/links/centos-7.8-x86_64
creating new profile: centos-7.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/ks_mirror/centos-7.8-x86_64 for centos-7.8-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos-7.8-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos-7.8-x86_64
looking for /var/www/cobbler/ks_mirror/centos-7.8-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos-7.8-x86_64/repodata
*** TASK COMPLETE ***
[aaa@qq.com ~]# cobbler import --name=centos-6.10-x86_64 --path=/mnt/centos6 --arch=x86_64
[aaa@qq.com ~]# du -sh /var/www/cobbler/ks_mirror/*
449M	/var/www/cobbler/ks_mirror/centos-6.10-x86_64
1001M	/var/www/cobbler/ks_mirror/centos-7.8-x86_64
6.8G	/var/www/cobbler/ks_mirror/centos-8.0-x86_64
12K	/var/www/cobbler/ks_mirror/config
[aaa@qq.com ~]# cobbler distro list
   centos-6.10-x86_64
   centos-7.8-x86_64
   centos-8.0-x86_64
[aaa@qq.com ~]# cobbler profile list
   CentOS-7.8_production
   CnetOS-8.0_production
   centos-6.10-x86_64

#默认生成的是最小化安装

CentOS 7基于cobbler实现系统的自动化安装

8 准备kickstart文件,并关联至指定的YUM源

[aaa@qq.com ~]# vim /var/lib/cobbler/kickstarts/centos8.cfg
ignoredisk --only-use=sda
zerombr
text
reboot
clearpart --all --initlabel
selinux --disabled
firewall --disabled
url --url=$tree	#注意此行必须指定
keyboard --vckeymap=us --xlayouts='us'
lang en_US.UTF-8
network --bootproto=dhcp --device=eth0 --ipv6=auto --activate
bootloader --append="net.ifnames=0" --location=mbr --boot-drive=sda
network --hostname=centos8.kobe.com
rootpw --iscrypted $6$ZqApgQaeO0mXFWe.$IBfhxqiDlWcrgIKkjexjBltP8R2UXdM/PkvQ4GvnXl25Zzcoh4ZrrhFv9.dEZrm6oSjEDSJ7KwonWEh54JsiL0
firstboot --enable
skipx
services --disabled="chronyd"
timezone Asia/Shanghai --isUtc --nontp
user --name=kobe --password=$6$7a9OGZdtOAnEiJtN$p7xoQYfKKEjCKTzUPxb4R3fW/.jrS7BoC14j3IUzF8LxgDTDJaxnhneby4F7dW/fQH6W/huYlkeuiFeaRxzC81 --iscrypted --gecos="kobe"
#autopart --type=lvm
#part / --fstype xfs --size 1 --grow --ondisk sda 可以实现根自动使用所有剩余空间
part / --fstype="xfs" --ondisk=sda --size=102400
part /data --fstype="xfs" --ondisk=sda --size=51200
part swap --fstype="swap" --ondisk=sda --size=2048
part /boot --fstype="ext4" --ondisk=sda --size=1024
%packages
@^minimal-environment
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
%post
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/* /etc/yum.repos.d/backup
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=CentOS-\$releasever Base
#baseurl=file:///misc/cd/BaseOS
baseurl=https://mirrors.aliyun.com/centos/\$releasever/BaseOS/\$basearch/os/
        https://mirrors.huaweicloud.com/centos/\$releasever/BaseOS/\$basearch/os/
enabled=1
gpgcheck=0

[AppStream]
name=CentOS-\$releasever Appstream
#baseurl=file:///misc/cd/AppStream
baseurl=https://mirrors.aliyun.com/centos/\$releasever/AppStream/\$basearch/os/
        https://mirrors.huaweicloud.com/centos/\$releasever/AppStream/\$basearch/os/
enabled=1
gpgcheck=0

[epel]
name=CentOS-\$releasever Epel
baseurl=https://mirrors.aliyun.com/epel/\$releasever/Everything/\$basearch/
        https://mirrors.huaweicloud.com/epel/\$releasever/Everything/\$basearch/
enabled=1
gpgcheck=0

[extras]
name=CentOS-\$releasever Extras
baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/os/
        https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/os/ 
enabled=1
gpgcheck=0
EOF
%end

[aaa@qq.com ~]# vim /var/lib/cobbler/kickstarts/centos7.cfg
install
xconfig --startxonboot
keyboard --vckeymap=us --xlayouts='us'
rootpw --iscrypted $6$ZqApgQaeO0mXFWe.$IBfhxqiDlWcrgIKkjexjBltP8R2UXdM/PkvQ4GvnXl25Zzcoh4ZrrhFv9.dEZrm6oSjEDSJ7KwonWEh54JsiL0
url --url=$tree
lang en_US
auth --useshadow --passalgo=sha512
text
firstboot --enable
selinux --disabled
skipx
services --disabled="chronyd"
ignoredisk --only-use=sda
firewall --disabled
network --bootproto=dhcp --device=eth0
network --hostname=centos7.kobe.com
reboot
timezone Asia/Shanghai --nontp
bootloader --append="net.ifnames=0" --location=mbr --boot-drive=sda
zerombr
#autopart --type=lvm
clearpart --all --initlabel
part swap --fstype="swap" --ondisk=sda --size=2048
part / --fstype="xfs" --ondisk=sda --size=102400
part /boot --fstype="xfs" --ondisk=sda --size=1024
part /data --fstype="xfs" --ondisk=sda --size=51200
%post
useradd kobe
echo centos | passwd --stdin kobe
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/* /etc/yum.repos.d/backup
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=CentOS-\$releasever Base
baseurl=https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/os/\$basearch/
enabled=1
gpgcheck=0

[epel]
name=CentOS-\$releasever Epel
baseurl=https://mirrors.aliyun.com/epel/\$releasever/\$basearch/
        https://mirrors.huaweicloud.com/epel/\$releasever/\$basearch/ 
enabled=1
gpgcheck=0

[extras]
name=CentOS-\$releasever Extras
baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/ 
enabled=1
gpgcheck=0
EOF
%end
%packages
@core
%end

[aaa@qq.com ~]# vim /var/lib/cobbler/kickstarts/centos6.cfg
install
text
reboot
url --url=$tree
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6 --hostname centos6.kobe.com
rootpw --iscrypted $6$ZqApgQaeO0mXFWe.$IBfhxqiDlWcrgIKkjexjBltP8R2UXdM/PkvQ4GvnXl25Zzcoh4ZrrhFv9.dEZrm6oSjEDSJ7KwonWEh54JsiL0
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone  Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
zerombr
clearpart --all --initlabel
part /boot --fstype=ext4 --size=1024
part / --fstype=ext4 --size=102400
part /data --fstype=ext4 --size=51200
part swap --size=2048
%packages
@core
@server-policy
@workstation-policy
%end
%post
useradd kobe
echo centos | passwd --stdin kobe &> /dev/null
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/* /etc/yum.repos.d/backup
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=CentOS-\$releasever Base
baseurl=https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/os/\$basearch/
enabled=1
gpgcheck=0

[epel]
name=CentOS-\$releasever Epel
baseurl=https://mirrors.aliyun.com/epel/\$releasever/\$basearch/
        https://mirrors.huaweicloud.com/epel/\$releasever/\$basearch/ 
enabled=1
gpgcheck=0

[extras]
name=CentOS-\$releasever Extras
baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/ 
enabled=1
gpgcheck=0
EOF
%end

#将kickstart文件,关联至指定的YUM源和生成菜单列表
[aaa@qq.com ~]# cobbler profile add --name=CentOS-8.0_production --distro=CentOS-8.0-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos8.cfg
[aaa@qq.com ~]# cobbler profile add --name=CentOS-7.8_production --distro=CentOS-7.8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg
[aaa@qq.com ~]# cobbler profile add --name=CnetOS-6.10_production --distro=CentOS-6.10-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.cfg

#删除默认生成的菜单
[aaa@qq.com ~]# cobbler profile remove --name=CentOS-8.0-x86_64
[aaa@qq.com ~]# cobbler profile remove --name=CentOS-7.8-x86_64
[aaa@qq.com ~]# cobbler profile remove --name=centos-6.10-x86_64

[aaa@qq.com ~]# cobbler profile list
   CentOS-7.8_production
   CnetOS-6.10_production
   CnetOS-8.0_production

9 测试客户端基于Cobbler实现自动安装

CentOS 7基于cobbler实现系统的自动化安装
安装成功示例:
CentOS 7基于cobbler实现系统的自动化安装
CentOS 7基于cobbler实现系统的自动化安装

10 支持UEFI安装

注意:CentOS6的虚拟机不支持UEFI
修改文件设置时间,默认不显示菜单

#修改模板文件
[aaa@qq.com ~]# vim /etc/cobbler/pxe/efidefault.template
default=0
timeout=60

$grub_menu_items

#使模板生效
[aaa@qq.com ~]# cobbler sync

#验证生效
[aaa@qq.com ~]# head -2 /var/lib/tftpboot/grub/efidefault 
default=0
timeout=60

设置客户端启动使用UEFI
CentOS 7基于cobbler实现系统的自动化安装
启动客户机可以如下界面
CentOS 7基于cobbler实现系统的自动化安装

选择对应的菜单进行自动安装
CentOS 7基于cobbler实现系统的自动化安装
CentOS 7基于cobbler实现系统的自动化安装
CentOS 7基于cobbler实现系统的自动化安装

11 实现cobbler的web管理

[aaa@qq.com ~]# yum -y install cobbler-web
[aaa@qq.com ~]# systemctl restart httpd

通过浏览器访问:https://10.0.0.7/cobbler_web
CentOS 7基于cobbler实现系统的自动化安装
点高级后,继续点访问10.0.0.7(不安全)
CentOS 7基于cobbler实现系统的自动化安装
CentOS 7基于cobbler实现系统的自动化安装
用户名:cobbler,密码:cobbler
CentOS 7基于cobbler实现系统的自动化安装
CentOS 7基于cobbler实现系统的自动化安装

12 创建cobbler自定义的web用户

[aaa@qq.com ~]# cat /etc/cobbler/users.digest 
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3
[aaa@qq.com ~]# htdigest -c /etc/cobbler/users.digest Cobbler admin
Adding password for admin in realm Cobbler.
New password: 
Re-type new password: 
[aaa@qq.com ~]# cat /etc/cobbler/users.digest 
admin:Cobbler:461941848a17e1b412f94c100a79bf75
3
[aaa@qq.com ~]# htdigest /etc/cobbler/users.digest Cobbler admin2
Adding user admin2 in realm Cobbler
New password: 
Re-type new password: 
[aaa@qq.com ~]# cat /etc/cobbler/users.digest 
admin:Cobbler:461941848a17e1b412f94c100a79bf75
3
admin2:Cobbler:8e3ab6cc196fac11dcf0512c200a672f

使用上面创建的用户登录web界面,登录成功后可以看到下面界面
CentOS 7基于cobbler实现系统的自动化安装
CentOS 7基于cobbler实现系统的自动化安装

相关标签: Linux运维 linux