diff --git a/confluent_osdeploy/common/profile/scripts/confignet b/confluent_osdeploy/common/profile/scripts/confignet index de29fe6e..e74e7f21 100644 --- a/confluent_osdeploy/common/profile/scripts/confignet +++ b/confluent_osdeploy/common/profile/scripts/confignet @@ -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']) diff --git a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/firstboot.sh b/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/firstboot.sh index 996bfffe..59560481 100755 --- a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/firstboot.sh +++ b/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/firstboot.sh @@ -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 diff --git a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/post.sh b/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/post.sh index 72ac0e58..78e6b411 100755 --- a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/post.sh +++ b/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/post.sh @@ -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