经过前面服务端的部署,已经配置好了 Cobbler Server 端,接下来开始进行 CentOS/Ubuntu 的批量安装,在进行 CentOS/Ubuntu 批量安装时,也须要经过Cobbler来作相应的发行版导入配置。流程以下:html
1、CentOS 配置过程:linux
将 CentOS-7-x64-Minimal-1708.iso 镜像拷贝至 cobbler server 服务器/root/目录下,在/mnt/ 目录下为其创建一个目录并挂载,以下:ubuntu
mkdir /mnt/centos7 mount -t iso9660 -o loop,ro CentOS-7-x64-Minimal-1708.iso /mnt/centos7/
成功挂载后,开始导入至 cobbler 中,以下:centos
cobbler import --path=/mnt/centos7/ --arch=x86_64 --name=centos7
导入成功后,会输出:*** TASK COMPLETE ***,截图以下:bash
导入镜像的同时,cobbler会自动生成该镜像的 profile 和 distro,能够经过 list 和 report 命令来查看细节,以下:服务器
cobbler list
cobbler report
从上图能够看到咱们导入的 centos7 使用的 Kickstart 文件是/var/lib/cobbler/kickstarts/sample_end.kskoa
前面两步的上传和导入ISO镜像都是基本步骤,无须解释。这里第三步配置ISO镜像自动值守安装文件的目的是用来设定ISO镜像在安装过程当中如何配置(也就是操做系统的那些设置,如硬盘分区、用户账号、密码等)。ssh
从第二步 “cobbler report” 中能够看到,导入的系统相关配置文件路径为/var/lib/cobbler/kickstarts/sample_end.ks,那么咱们就能够修改该文件,在该文件中来指定操做系统安装的设置(事实上,咱们能够在第二步中指定具体的配置,未指定才会使用该默认文件),配置以下:ide
auth --useshadow --enablemd5 bootloader --location=mbr clearpart --all --initlabel graphical firewall --enabled firstboot --disable keyboard us lang en_US url --url=$tree $yum_repo_stanza $SNIPPET('network_config') reboot #Root password rootpw --iscrypted $default_password_crypted selinux --disabled skipx timezone America/New_York install zerombr autopart %pre $SNIPPET('log_ks_pre') $SNIPPET('kickstart_start') $SNIPPET('pre_install_network_config') $SNIPPET('pre_anamon') %end %packages $SNIPPET('func_install_if_enabled') %end %post --nochroot $SNIPPET('log_ks_post_nochroot') %end %post $SNIPPET('log_ks_post') $yum_config_stanza $SNIPPET('post_install_kernel_options') $SNIPPET('post_install_network_config') $SNIPPET('func_register_if_enabled') $SNIPPET('download_config_files') $SNIPPET('koan_environment') $SNIPPET('redhat_register') $SNIPPET('cobbler_register') $SNIPPET('post_anamon') $SNIPPET('kickstart_done') %end
以上是一个简单配置文件,具体定制能够参考这里:KICKSTART 语法参考。oop
2、Ubuntu 配置过程:
将 ubuntu-16.04.3-server-x64.iso 镜像拷贝至 cobbler server 服务器/root/目录下,在/mnt/ 目录下为其创建一个目录并挂载,以下:
mkdir /mnt/ubuntu16 mount -t iso9660 -o loop,ro ubuntu-16.04.3-server-x64.iso /mnt/ubuntu16
成功挂载后,开始导入至 cobbler 中,以下:
cobbler import --name=ubuntu16 --path=/mnt/ubuntu16/ --breed=ubuntu
导入成功后,会输出:*** TASK COMPLETE ***,截图以下:
在导入ISO镜像时,会有不少的标准错误输出,以下:
这里出现了不少这样的错误,最终导入其实是成功的,可是不知道为何这里出现了错误,推测多是Cobbler的bug,该服务多是在哪里重定向了标准输出至标准错误,使得程序误觉得导入过程当中出现问题(仅推测)。对于这样的错误忽略便可。
在导入Ubuntu 16.04的ISO镜像时,还额外生成了一个系统,以下:
这里生成的系统是一个快捷方式,至于为何生成,不得而知。
导入镜像的同时,Cobbler会自动生成该镜像的 profile 和 distro,能够经过 list 和 report 命令来查看细节,以下:
从上图能够看到咱们导入的 Ubuntu 16.04 使用的 preseed 文件是/var/lib/cobbler/kickstarts/sample.seed
这里的第三步和 CentOS 系统同样,也是用来设定ISO镜像在安装过程当中如何配置
d-i debian-installer/locale string en_US d-i console-setup/ask_detect boolean false d-i keyboard-configuration/toggle select No toggling d-i keyboard-configuration/layoutcode string us d-i keyboard-configuration/variantcode string d-i netcfg/choose_interface select auto d-i netcfg/get_hostname string $myhostname d-i time/zone string US/Eastern d-i clock-setup/utc boolean true d-i clock-setup/ntp boolean true d-i clock-setup/ntp-server string ntp.ubuntu.com d-i mirror/country string manual d-i mirror/http/hostname string $http_server d-i mirror/http/directory string $install_source_directory d-i mirror/http/proxy string d-i live-installer/net-image string http://$http_server/cobbler/links/$distro_name/install/filesystem.squashfs d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true d-i partman-auto/method string lvm d-i partman-lvm/device_remove_lvm boolean true d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true d-i partman-md/device_remove_md boolean true d-i partman-partitioning/confirm_write_new_label boolean true d-i partman-auto/choose_recipe select atomic d-i passwd/root-login boolean true d-i passwd/root-password-crypted password $default_password_crypted d-i passwd/make-user boolean false $SNIPPET('preseed_apt_repo_config') tasksel tasksel/first multiselect standard d-i pkgsel/include string ntp ssh wget d-i grub-installer/grub2_instead_of_grub_legacy boolean true d-i grub-installer/bootdev string default d-i debian-installer/add-kernel-opts string $kernel_options_post d-i finish-install/reboot_in_progress note d-i preseed/early_command string wget -O- \ http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_early_default | \ /bin/sh -s d-i preseed/late_command string wget -O- \ http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_late_default | \ chroot /target /bin/sh -s
以上是一个简单配置文件,具体定制能够参考这里:Preseed语法参考。