cobbler部署ctyunos
1.环境:vmware、centos7
本机ip: 172.25.2.100
2. 安装cobbler
yum -y install cobbler cobbler-web dhcp-server dhcp tftp-server xinetd
3. 关闭防火墙、selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/sysconfig/selinux
4. 部署cobbler
执行cobbler check,根据提示修改相关配置文件
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.
# 设置PXE文件
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.
# 设置tftp
3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
# 把网络的boot-loaders通过cobbler get-loaders后放在/var/lib/cobbler/loaders
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.
# 启动rsync服务
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 : 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
#
8 : 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.
-----------------------------------------------------------------------------------------------
comment out 'dists' on /etc/debmirror.conf for proper debian support
comment out 'arches' on /etc/debmirror.conf for proper debian support
注释掉 /etc/debmirror.conf配置文件中的 @dists="sid"; 和 @arches="i386";
再次执行 cobbler check,cobbler配置成功
5. 配置DHCP, 将manage_dhcp设置为1
vim /etc/cobbler/settings
根据本机ip修改以下文件
vim /etc/cobbler/dhcp.template
(如果有网关和DNS需要改为相应的地址 )
6. 重启服务并同步配置,改完dhcp必须要sync同步配置。
systemctl restart cobblerd
cobbler sync
7. ISO配置
7.1 通过挂载镜像的方式存放iso
mount -o loop /home/ctyunos-2.0.1-210625-x86_64-dvd.iso /mnt/
cobbler import --path=/mnt --name=ctyunos-test-x86_64 --arch=x86_64
注: 在导入的时候可能会报错
在导入ctyunos时,需要手动添加ctyunos相关的signature信息
vim /var/lib/cobbler/distro_signatures.json
#添加如下信息
----------------------------------------------------------------------------
"ctyunos": {
"signatures": [
"Packages"
],
"version_file": "ctyunos-release-(.*)\\.rpm",
"version_file_regex": null,
"kernel_arch": "kernel-(.*).rpm",
"kernel_arch_regex": null,
"supported_arches": [
"i386",
"x86_64",
"ppc",
"ppc64",
"ppc64le"
],
"supported_repo_breeds": [
"rsync",
"rhn",
"yum"
],
"kernel_file": "vmlinuz(.*)",
"initrd_file": "initrd(.*)\\.img",
"isolinux_ok": false,
"default_kickstart": "/var/lib/cobbler/kickstarts/sample_end.ks",
"kernel_options": "",
"kernel_options_post": "",
"boot_files": []
},
---------------------------------------------------------------------------------------------------
添加完成之后需重启cobbler服务
systemctl restart cobblerd
cobbler sync
导入镜像完成后,可通过cobbler list查看
cobbler list
7.2 配置ks文件
cd /var/lib/cobbler/kickstarts/
vim ctyunos.ks (说明:可随系统名称命名)(ip设置为本机ip)
参考.ks文件
------------------------------------------------------------------------------------------------------
#cat /var/lib/cobbler/kickstarts/ks-ctyunos/ks-ctyunos2-x86_64.cfg
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
#$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part / --fstype="xfs" --ondisk=sda --size=51200
part /var --fstype="xfs" --ondisk=sda --size=1 --grow
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
$SNIPPET('pre_anamon')
%end
%packages
@^minimal-environment
%end
%anaconda
%end
%post
curl -o /root/host_init.sh http://172.25.2.100/ks_config/host_install/host_init.sh &>/dev/null
/bin/bash /root/host_init.sh
%end
----------------------------------------------------------------------------------------
指定使用新的 kickstart 文件:
cobbler profile edit --name=ctyunos-test-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ctyunos.ks
验证本次配置的镜像与 ks 文件配置路径:
cobbler profile report --name=UOS_Server-x86_64 |grep Kickstart
8. 使用vmware创建一个新的虚拟机
8.1 关掉DHCP服务
8.2 设置cobbler服务器和新创建的虚拟机网络为“仅主机模式”
“启动客户机”开始安装系统