2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-06-10 01:53:09 +00:00

Fixes for confignet for Ubuntu

Try to find various layers of network config and normalize.

Ultimately, after post subiquity will do some things and easiest to fix in firstboot instead.
This commit is contained in:
Jarrod Johnson
2026-06-01 16:49:42 -04:00
parent 842144ccab
commit 431d4992e0
3 changed files with 26 additions and 13 deletions
@@ -245,18 +245,31 @@ class NetplanManager(object):
planout.write(yaml.dump(newcfg))
os.umask(oumask)
if prune_from_cloudinit:
with open('/etc/netplan/50-cloud-init.yaml', 'r') as cloudinit:
cloudinfo = yaml.safe_load(cloudinit)
for clouddev in list(cloudinfo.get('network', {}).get('ethernets', {})):
if clouddev in prune_from_cloudinit:
del cloudinfo['network']['ethernets'][clouddev]
if not cloudinfo['network'].get('ethernets', {}):
os.remove('/etc/netplan/50-cloud-init.yaml')
else:
oumask = os.umask(0o77)
with open('/etc/netplan/50-cloud-init.yaml', 'w') as cloudinit:
cloudinit.write(yaml.dump(cloudinfo))
os.umask(oumask)
prunecfgs = ['/etc/netplan/00-installer-config.yaml',
'/etc/netplan/50-cloud-init.yaml.dist-subiquity',
'/etc/netplan/50-cloud-init.yaml']
prunecfgs.extend(glob.glob('/etc/cloud/cloud.cfg.d/*.cfg'))
for defcfg in prunecfgs:
if not os.path.exists(defcfg):
continue
with open(defcfg, 'r') as cloudinit:
cloudinfo = yaml.safe_load(cloudinit)
if 'network' not in cloudinfo:
continue
for clouddev in list(cloudinfo.get('network', {}).get('ethernets', {})):
if clouddev in prune_from_cloudinit:
del cloudinfo['network']['ethernets'][clouddev]
if not cloudinfo['network'].get('ethernets', {}):
os.remove(defcfg)
if '/etc/cloud/cloud.cfg.d/' in defcfg:
# need to also change datasource, probably
if os.path.exists('/var/lib/cloud/instances/iid-datasource-none/network-config.json'):
os.remove('/var/lib/cloud/instances/iid-datasource-none/network-config.json')
else:
oumask = os.umask(0o77)
with open(defcfg, 'w') as cloudinit:
cloudinit.write(yaml.dump(cloudinfo))
os.umask(oumask)
if needcfgapply:
subprocess.check_call(['netplan', 'generate'])
subprocess.call(['netplan', 'apply'])
@@ -23,6 +23,7 @@ touch /etc/cloud/cloud-init.disabled
source /etc/confluent/functions
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg|awk '{print $2}')
export confluent_mgr confluent_profile
run_remote_python confignet
run_remote_parts firstboot.d
run_remote_config firstboot.d
curl --capath /etc/confluent/tls -f -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" -X POST -d "status: complete" https://$confluent_mgr/confluent-api/self/updatestatus
@@ -89,7 +89,6 @@ chroot /target update-ca-certificates
chroot /target bash -c "source /etc/confluent/functions; run_remote_python autoconsole"
chroot /target bash -c "source /etc/confluent/functions; run_remote_python syncfileclient"
chroot /target bash -c "source /etc/confluent/functions; run_remote_python confignet"
chroot /target bash -c "source /etc/confluent/functions; run_remote_parts post.d"
source /target/etc/confluent/functions