rhel: 使用 alpine 的 cloud-init 生成 sysconfig 配置

This commit is contained in:
bin456789
2026-09-06 11:31:37 +08:00
parent fb830009eb
commit 388bf257e9
+19
View File
@@ -5419,6 +5419,9 @@ EOF
# sysconfig # sysconfig
info 'sysconfig' info 'sysconfig'
# 使用目标系统内的 cloud-init
# 保留这个,防止未来新版本 cloud-init 不支持 sysconfig
if false; then
# anolis/openeuler/opencloudos 可能要安装 cloud-init # anolis/openeuler/opencloudos 可能要安装 cloud-init
# opencloudos 无法使用 chroot $os_dir command -v xxx # opencloudos 无法使用 chroot $os_dir command -v xxx
# chroot: failed to run command ‘command’: No such file or directory # chroot: failed to run command ‘command’: No such file or directory
@@ -5470,6 +5473,22 @@ EOF
# 清理 # 清理
rm -rf $os_dir/net.cfg $os_dir/out rm -rf $os_dir/net.cfg $os_dir/out
else
# 使用 alpine 的 cloud-init
# 生成 cloud-init 网络配置
create_cloud_init_network_config net.cfg
# 转换成目标系统的网络配置
apk add cloud-init-distros
cloud-init devel net-convert \
-p /net.cfg -k yaml -d out -D rhel -O sysconfig
cp out/etc/sysconfig/network-scripts/ifcfg-eth* $os_dir/etc/sysconfig/network-scripts/
# 清理
rm -rf net.cfg out
apk del cloud-init-distros
fi
# 删除 # Created by cloud-init on instance boot automatically, do not edit. # 删除 # Created by cloud-init on instance boot automatically, do not edit.
# 修正网络配置问题并显示文件 # 修正网络配置问题并显示文件