Cobbler的使用(三)

一、挂载并导入ISO镜像

  • 加载镜像
shell> mount -t auto -o loop CentOS-6.9-x86_64-bin-DVD1.iso /mnt/
  • 导入ISO镜像
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位或64位,目前支持的选项有:x86 | x86_64 | ia64
# 安装源的唯一标识就是根据name参数来定义的,本例导入成功后,标识就是CentOS-6.9-x86_64,如果重复,系统会提示导入失败。
shell> cobbler import --path=/mnt/ --name=CentOS-6.9-x86_64 --arch=x86_64

二、配置ks.cfg

  • 查看安装镜像文件信息
# 在第一次导入系统镜像后,cobbler会给镜像指定一个默认的kickstart自动安装文件在 /var/lib/cobbler/kickstarts下的sample_end.ks
shell> cobbler profile report --name=CentOS-6.9-x86_64
Name : CentOS-6.9-x86_64
TFTP Boot Files : {}
Comment : 
DHCP Tag : default
Distribution : CentOS-6.9-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
  • 创建ks.cfg文件
shell> cat CentOS-6.9-x86_64.ks
unsupported_hardware
install
text
url --url=$tree
lang en_US.UTF-8
keyboard us
skipx
network --device em1 --bootproto dhcp --noipv6 --onboot=no --hostname 91donkeyOS
rootpw --iscrypted $default_password_crypted
firewall --disable
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
firstboot --disable
%include /tmp/fdisk
reboot

%post
/bin/mv -fv /etc/udev/rules.d/70-persistent-net.rules /etc/sysconfig/network-scripts/ifcfg-em* /etc/sysconfig/network-scripts/ifcfg-p* /tmp/
/bin/cp -fv /boot/grub/grub.conf /tmp/

i=0
for IfCard in `find /tmp/ -type f -name "ifcfg-*" | sort`
do
    sed "s/DEVICE=.*/DEVICE=eth${i}/g" $IfCard > /etc/sysconfig/network-scripts/ifcfg-eth${i} # device=ethX
    sed -ci 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-eth* # onboot=yes
    #sed -i 's/\(BOOTPROTO=\).*/\1static/g' /etc/sysconfig/network-scripts/ifcfg-eth* # bootproto=static
    sed -ci 's/\(BOOTPROTO=\).*/\1dhcp/g' /etc/sysconfig/network-scripts/ifcfg-eth* # bootproto=dhcp 
    echo "ARPCHECK=no" >> /etc/sysconfig/network-scripts/ifcfg-eth${i}
    i=`echo $(($i+1))`
done

# disable grub:rhgb
sed -ci 's/rhgb//' /etc/grub.conf

# disable ipv6
cat << EOF >> /etc/modprobe.d/dist.conf
options ipv6 disable=1
EOF

cat << EOF >> /etc/sysconfig/network
NETWORKING_IPV6=off
EOF

%packages
acl-2.2.49-7.el6.x86_64
attr-2.4.44-7.el6.x86_64
audit-2.4.5-6.el6.x86_64
audit-libs-2.4.5-6.el6.x86_64
authconfig-6.1.12-23.el6.x86_64
b43-openfwwf-5.2-10.el6.noarch
basesystem-10.0-4.el6.noarch
bash-4.1.2-48.el6.x86_64
binutils-2.20.51.0.2-5.46.el6.x86_64
bzip2-1.0.5-7.el6_0.x86_64
bzip2-libs-1.0.5-7.el6_0.x86_64
ca-certificates-2016.2.10-65.4.el6.noarch
centos-release-6-9.el6.12.3.x86_64
checkpolicy-2.0.22-1.el6.x86_64
chkconfig-1.3.49.5-1.el6.x86_64
coreutils-8.4-46.el6.x86_64
coreutils-libs-8.4-46.el6.x86_64
cpio-2.10-13.el6.x86_64
cracklib-2.8.16-4.el6.x86_64
cracklib-dicts-2.8.16-4.el6.x86_64
cronie-1.4.4-16.el6_8.2.x86_64
cronie-anacron-1.4.4-16.el6_8.2.x86_64
crontabs-1.10-33.el6.noarch
curl-7.19.7-52.el6.x86_64
cyrus-sasl-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-lib-2.1.23-15.el6_6.2.x86_64
dash-0.5.5.1-4.el6.x86_64
db4-4.7.25-22.el6.x86_64
db4-utils-4.7.25-22.el6.x86_64
dbus-glib-0.86-6.el6.x86_64
dbus-libs-1.2.24-8.el6_6.x86_64
device-mapper-1.02.117-12.el6.x86_64
device-mapper-event-1.02.117-12.el6.x86_64
device-mapper-event-libs-1.02.117-12.el6.x86_64
device-mapper-libs-1.02.117-12.el6.x86_64
device-mapper-persistent-data-0.6.2-0.1.rc7.el6.x86_64
diffutils-2.8.1-28.el6.x86_64
dmidecode-2.12-7.el6.x86_64
dnsmasq-2.48-17.el6.x86_64
dracut-004-409.el6_8.2.noarch
dracut-kernel-004-409.el6_8.2.noarch
e2fsprogs-1.41.12-23.el6.x86_64
e2fsprogs-libs-1.41.12-23.el6.x86_64
efibootmgr-0.5.4-15.el6.x86_64
elfutils-libelf-0.164-2.el6.x86_64
ethtool-3.5-6.el6.x86_64
expat-2.0.1-13.el6_8.x86_64
file-5.04-30.el6.x86_64
file-libs-5.04-30.el6.x86_64
filesystem-2.4.30-3.el6.x86_64
findutils-4.4.2-9.el6.x86_64
fipscheck-1.2.0-7.el6.x86_64
fipscheck-lib-1.2.0-7.el6.x86_64
gamin-0.1.10-9.el6.x86_64
gawk-3.1.7-10.el6_7.3.x86_64
gdbm-1.8.0-39.el6.x86_64
glib2-2.28.8-9.el6.x86_64
glibc-2.12-1.209.el6.x86_64
glibc-common-2.12-1.209.el6.x86_64
gmp-4.3.1-12.el6.x86_64
gnupg2-2.0.14-8.el6.x86_64
gpgme-1.1.8-3.el6.x86_64
gpm-1.20.6-12.el6.x86_64
gpm-libs-1.20.6-12.el6.x86_64
grep-2.20-6.el6.x86_64
groff-1.18.1.4-21.el6.x86_64
grub-0.97-99.el6.x86_64
grubby-7.0.15-7.el6.x86_64
gzip-1.3.12-24.el6.x86_64
hesiod-3.1.0-19.el6.x86_64
hwdata-0.233-18.1.el6.noarch
info-4.13a-8.el6.x86_64
initscripts-9.03.58-1.el6.centos.x86_64
iproute-2.6.32-54.el6.x86_64
iptables-1.4.7-16.el6.x86_64
iptables-ipv6-1.4.7-16.el6.x86_64
iputils-20071127-24.el6.x86_64
kbd-1.15-11.el6.x86_64
kbd-misc-1.15-11.el6.noarch
kernel-2.6.32-696.el6.x86_64
kernel-firmware-2.6.32-696.el6.noarch
keyutils-libs-1.4-5.el6.x86_64
krb5-libs-1.10.3-65.el6.x86_64
less-436-13.el6.x86_64
libacl-2.2.49-7.el6.x86_64
libattr-2.4.44-7.el6.x86_64
libblkid-2.17.2-12.28.el6.x86_64
libcap-2.16-5.5.el6.x86_64
libcap-ng-0.6.4-3.el6_0.1.x86_64
libcom_err-1.41.12-23.el6.x86_64
libcurl-7.19.7-52.el6.x86_64
libdrm-2.4.65-2.el6.x86_64
libffi-3.0.5-3.2.el6.x86_64
libgcc-4.4.7-18.el6.x86_64
libgcrypt-1.4.5-12.el6_8.x86_64
libgpg-error-1.7-4.el6.x86_64
libidn-1.18-2.el6.x86_64
libnih-1.0.1-7.el6.x86_64
libpcap-1.4.0-4.20130826git2dbcaa1.el6.x86_64
libpciaccess-0.13.4-1.el6.x86_64
libselinux-2.0.94-7.el6.x86_64
libselinux-utils-2.0.94-7.el6.x86_64
libsemanage-2.0.43-5.1.el6.x86_64
libsepol-2.0.41-4.el6.x86_64
libss-1.41.12-23.el6.x86_64
libssh2-1.4.2-2.el6_7.1.x86_64
libstdc++-4.4.7-18.el6.x86_64
libtasn1-2.3-6.el6_5.x86_64
libudev-147-2.73.el6_8.2.x86_64
libusb-0.1.12-23.el6.x86_64
libuser-0.56.13-8.el6_7.x86_64
libutempter-1.1.5-4.1.el6.x86_64
libuuid-2.17.2-12.28.el6.x86_64
libxml2-2.7.6-21.el6_8.1.x86_64
logrotate-3.7.8-28.el6.x86_64
lrzsz-0.12.20-27.1.el6.x86_64
lsof-4.82-5.el6.x86_64
lua-5.1.4-4.1.el6.x86_64
m4-1.4.13-5.el6.x86_64
make-3.81-23.el6.x86_64
MAKEDEV-3.24-6.el6.x86_64
mingetty-1.08-5.el6.x86_64
module-init-tools-3.9-26.el6.x86_64
ncurses-5.7-4.20090207.el6.x86_64
ncurses-base-5.7-4.20090207.el6.x86_64
ncurses-libs-5.7-4.20090207.el6.x86_64
net-tools-1.60-114.el6.x86_64
newt-0.52.11-4.el6.x86_64
newt-python-0.52.11-4.el6.x86_64
nspr-4.13.1-1.el6.x86_64
nss-3.27.1-13.el6.x86_64
nss-softokn-3.14.3-23.3.el6_8.x86_64
nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64
nss-sysinit-3.27.1-13.el6.x86_64
nss-tools-3.27.1-13.el6.x86_64
nss-util-3.27.1-3.el6.x86_64
openldap-2.4.40-16.el6.x86_64
openssh-5.3p1-122.el6.x86_64
openssh-clients-5.3p1-122.el6.x86_64
openssh-server-5.3p1-122.el6.x86_64
openssl-1.0.1e-57.el6.x86_64
p11-kit-0.18.5-2.el6_5.2.x86_64
p11-kit-trust-0.18.5-2.el6_5.2.x86_64
pam-1.1.1-24.el6.x86_64
passwd-0.77-7.el6.x86_64
pciutils-libs-3.1.10-4.el6.x86_64
pcre-7.8-7.el6.x86_64
perl-5.10.1-144.el6.x86_64
perl-libs-5.10.1-144.el6.x86_64
perl-Module-Pluggable-3.90-144.el6.x86_64
perl-Pod-Escapes-1.04-144.el6.x86_64
perl-Pod-Simple-3.13-144.el6.x86_64
perl-version-0.77-144.el6.x86_64
pinentry-0.7.6-8.el6.x86_64
pkgconfig-0.23-9.1.el6.x86_64
plymouth-0.8.3-29.el6.centos.x86_64
plymouth-core-libs-0.8.3-29.el6.centos.x86_64
plymouth-scripts-0.8.3-29.el6.centos.x86_64
policycoreutils-2.0.83-30.1.el6_8.x86_64
popt-1.13-7.el6.x86_64
procmail-3.22-25.1.el6_5.1.x86_64
procps-3.2.8-45.el6.x86_64
psmisc-22.6-24.el6.x86_64
pth-2.0.7-9.3.el6.x86_64
pygpgme-0.1-18.20090824bzr68.el6.x86_64
python-2.6.6-66.el6_8.x86_64
python-iniparse-0.3.1-2.1.el6.noarch
python-libs-2.6.6-66.el6_8.x86_64
python-pycurl-7.19.0-9.el6.x86_64
python-urlgrabber-3.9.1-11.el6.noarch
readline-6.0-4.el6.x86_64
redhat-logos-60.0.14-12.el6.centos.noarch
rootfiles-8.1-6.1.el6.noarch
rpm-4.8.0-55.el6.x86_64
rpm-libs-4.8.0-55.el6.x86_64
rpm-python-4.8.0-55.el6.x86_64
rsyslog-5.8.10-10.el6_6.x86_64
sed-4.2.1-10.el6.x86_64
sendmail-8.14.4-9.el6_8.1.x86_64
setup-2.8.14-23.el6.noarch
shadow-utils-4.1.5.1-5.el6.x86_64
shared-mime-info-0.70-6.el6.x86_64
slang-2.2.1-1.el6.x86_64
sqlite-3.6.20-1.el6_7.2.x86_64
sudo-1.8.6p3-27.el6.x86_64
sysstat-9.0.4-33.el6.x86_64
system-config-firewall-base-1.2.27-7.2.el6_6.noarch
sysvinit-tools-2.87-6.dsf.el6.x86_64
tar-1.23-15.el6_8.x86_64
tcpdump-4.0.0-11.20090921gitdf3cb4.2.el6.x86_64
tcp_wrappers-libs-7.6-58.el6.x86_64
tzdata-2016j-1.el6.noarch
udev-147-2.73.el6_8.2.x86_64
upstart-0.6.5-16.el6.x86_64
ustr-1.0.4-9.1.el6.x86_64
util-linux-ng-2.17.2-12.28.el6.x86_64
vim-enhanced-7.4.629-5.el6_8.1.x86_64
vim-minimal-7.4.629-5.el6_8.1.x86_64
wget-1.12-10.el6.x86_64
which-2.19-6.el6.x86_64
xz-libs-4.999.9-0.5.beta.20091007git.el6.x86_64
yum-3.2.29-81.el6.centos.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64
yum-plugin-fastestmirror-1.1.30-40.el6.noarch
yum-utils-1.1.30-40.el6.noarch
zlib-1.2.3-29.el6.x86_64
  • 编辑profile,修改关联的ks文件
shell> cobbler profile edit --name=CentOS-6.9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.9-x86_64.ks
  • 再次查看安装镜像文件信息,kickstart的配置cfg文件地址被改变了。
shell> cobbler profile report --name=CentOS-6.9-x86_64
Name : CentOS-6.9-x86_64
TFTP Boot Files : {}
Comment : 
DHCP Tag : default
Distribution : CentOS-6.9-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/CentOS-6.9-x86_64.ks
  • 同步cobbler数据,每次修改完都要镜像同步
shell> cobbler sync
上一篇:CentOS 8.2使用pgAdmin安装PostgreSQL


下一篇:docker-compose 安装