执行 cobbler sync 命令后,启动引导菜单文件 /var/lib/tftpboot/pxelinux.cfg/default 中 openEuler 操作系统的 append_line 没有生成 inst.ks=···· 相关内容或 inst.ks=···· 变为 ks=····?

**问题描述:**执行 cobbler sync 命令后,启动引导菜单文件 /var/lib/tftpboot/pxelinux.cfg/default 中 openEuler 操作系统的 append_line 没有生成 inst.ks=···· 相关内容或 inst.ks=···· 变为 ks=····,如下所示:


执行 cobbler sync 命令后:

**解决方案:**若基于 CentOS 操作系统搭建的 cobbler,则修改 /usr/lib/python2.7/site-packages/cobbler/pxegen.py 文件;若基于 openEuler 操作系统搭建的 cobbler,则修改 /usr/lib/python3.9/site-packages/cobbler/tftpgen.py 文件,如下所示:

(1)基于 CentOS 操作系统搭建的 cobbler 的修改方法

# 备份原文件
$ cp -a /usr/lib/python2.7/site-packages/cobbler/pxegen.py /usr/lib/python2.7/site-packages/cobbler/pxegen.py.bak

# 修改文件,添加以下代码
$ sed -i '/distro.breed == "suse"/i \            elif distro.breed == "openeuler":' /usr/lib/python2.7/site-packages/cobbler/pxegen.py
$ sed -i '/distro.breed == "suse"/i \                append_line = "%s inst.ks=%s" % (append_line, kickstart_path)' /usr/lib/python2.7/site-packages/cobbler/pxegen.py
$ sed -i '/distro.breed == "suse"/i \                append_line = append_line.replace("lang= ", "")' /usr/lib/python2.7/site-packages/cobbler/pxegen.py
$ sed -i '/distro.breed == "suse"/i \                append_line = append_line.replace("text ", "")' /usr/lib/python2.7/site-packages/cobbler/pxegen.py
$ sed -i '/distro.breed == "suse"/i \                append_line = append_line.replace("ksdevice=bootif ", "")' /usr/lib/python2.7/site-packages/cobbler/pxegen.py

修改后的文件如下图所示:


修改完成后,重启 cobbler 服务,重新执行 cobbler sync 命令,发现 /var/lib/tftpboot/pxelinux.cfg/default 中 openEuler 的 appen_line 已正常:

(2)基于 openEuler 操作系统搭建的 cobbler 的修改方法

# 备份原文件
$ cp -a /usr/lib/python3.9/site-packages/cobbler/tftpgen.py /usr/lib/python3.9/site-packages/cobbler/tftpgen.py.bak

# 修改 /usr/lib/python3.9/site-packages/cobbler/tftpgen.py 文件,约 730 行处
$ sed -i -e '/distro.breed == "openeuler"/ s/or distro.breed == "openeuler"//g' \
		 -e '/distro.breed == "suse"/i \            elif distro.breed == "openeuler":' \
		 -e '/distro.breed == "suse"/i \                append_line += f" inst.kssendmac inst.ks={autoinstall_path}"' /usr/lib/python3.9/site-packages/cobbler/tftpgen.py

修改后的文件如下图所示:


修改完成后,重启 cobbler 服务,重新执行 cobbler sync 命令,发现 /var/lib/tftpboot/pxelinux.cfg/default 中 openEuler 的 appen_line 已正常:

4 Likes

好贴必赞!

1 Like