环境准备
OS: CentOS 7.6 IP: 192.168.1.22
关闭防火墙
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
systemctl stop firewalld.service
systemctl disable firewalld.service
阿里云源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安装Cobbler
安装cobbler
yum install cobbler cobbler-web dhcp debmirror pykickstart fence-agents -y
开机启动
systemctl start cobblerd httpd tftp
systemctl enable cobblerd httpd tftp
访问cobbler web
https://IP/cobbler_web
注意是HTTPS, 账号密码都是cobbler
配置 Cobbler
IP_ADDR=192.168.1.22
sed -i 's/server: 127.0.0.1/server: '${IPADDR}'/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: '${IPADDR}'/' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
sed -i "s#manage_rsync: 0#manage_rsync: 1#g" /etc/cobbler/settings
cat /etc/cobbler/settings
server: 192.168.1.22
next_server: 192.168.1.22
manage_dhcp: 1
pxe_just_once: 1
manage_rsync: 1
设置root密码
openssl passwd -1 -salt root root_passwd
vim /etc/cobbler/settings
default_password_crypted: "$1$root$8BMsE/dbZudpinCK7fG0L/"
配置xinetd
vim /etc/xinetd.d/tftp
disable = no
配置debmirror
sed -i 's/@dists="sid";/#@dists="sid";/g' /etc/debmirror.conf
sed -i 's/@arches="i386";/#@arches="i386";/g' /etc/debmirror.conf
下载引导文件
cobbler get-loaders
# 提示 No such command: get-loaders 解决
yum install -y syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
配置dhcp文件
vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name-servers 192.168.1.10;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.60 192.168.1.120;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
同步检查
systemctl restart cobblerd
cobbler sync
cobbler check
导入镜像
# 试过导入 ubuntu-18.04.6-live-server-amd64.iso 失败
wget https://old-releases.ubuntu.com/releases/18.04/ubuntu-18.04.5-server-amd64.iso
# 系统镜像准备
mount ubuntu-18.04.5-server-amd64.iso /mnt
# 导入镜像
cobbler import --path=/mnt --name=ubuntu-18.04.5 --arch=x86_64
cobbler profile getks --name ubuntu-18.04.5-x86_64
Kickstart Templates
Configuration -> Kickstart Templates -> Create New Kickstart File
对应网址:https://IP/cobbler_web/ksfile/list
Filename: ubuntu1804.seed
https://github.com/sundayfly/cobbler-example/blob/main/ubuntu1804.seed
### Preseed for Ubuntu 18.04 LTS ###
# Install language packs
d-i debian-installer/locale string en_US.UTF-8
# Keyboard selection
d-i keyboard-configuration/xkb-keymap select us
# Network configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string ubuntu
d-i netcfg/disable_autoconfig boolean true
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
d-i netcfg/get_ipaddress string
d-i netcfg/get_netmask string
d-i netcfg/get_gateway string
d-i netcfg/get_nameservers string
d-i netcfg/confirm_static boolean true
# Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string mirrors.aliyun.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
# Clock and time zone setup
d-i clock-setup/utc boolean true
d-i time/zone string US/Pacific
# Partitioning
d-i partman-auto/method string regular
d-i partman-auto/expert_recipe string \
boot-root :: \
512 512 512 ext4 \
$primary{ } \
$bootable{ } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
mountpoint{ /boot } \
. \
10000 30000 -1 xfs \
$primary{ } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ xfs } \
mountpoint{ / } \
.
d-i partman-auto/choose_recipe boot-root
d-i partman/default_filesystem ext4
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# System package selection
tasksel tasksel/first multiselect standard
d-i pkgsel/include string openssh-server build-essential
# Package selection
tasksel tasksel/first multiselect standard
d-i pkgsel/include string openssh-server build-essential
d-i pkgsel/update-policy select none
d-i pkgsel/upgrade select none
# User account
d-i passwd/user-fullname string Ubuntu User
d-i passwd/username string ubuntu
d-i passwd/user-password password insecure
d-i passwd/user-password-again password insecure
d-i user-setup/encrypt-home boolean false
# Finish installation
d-i finish-install/reboot_in_progress note
导入ESXI Dell定制版报错解决
received on stderr:
No signature matched in /var/www/cobbler/ks_mirror/ESXi-6.5.0-Dell-A10-x86_64
!!! TASK FAILED !!!
cobbler import --path=/mnt --name=ESXi-6.5.0-Dell-A10 --arch=x86_64
cobbler signature update
参考链接
PXE+Cobbler批量部署操作系统
Cobbler2.x.x实现系统自动化安装系统
Cobbler 3.x 部署实战
CentOS7.4安装cobbler实现自动化安装ubuntu18.04
improt ESXi 6.5 to cobbler