diff --git a/cloudinit/net/netplan.py b/cloudinit/net/netplan.py index 96341a5a506..cf874756428 100644 --- a/cloudinit/net/netplan.py +++ b/cloudinit/net/netplan.py @@ -243,7 +243,9 @@ def _clean_default(target=None): os.unlink(f) -def netplan_api_write_yaml_file(net_config_content: str) -> bool: +def netplan_api_write_yaml_file( + net_config_content: str, target: Optional[str] = None +) -> bool: """Use netplan.State._write_yaml_file to write netplan config Where netplan python API exists, prefer to use of the private @@ -281,9 +283,11 @@ def netplan_api_write_yaml_file(net_config_content: str) -> bool: # determine default root-dir /etc/netplan and/or specialized # filenames or read permissions based on whether this config # contains secrets. - state_output_file._write_yaml_file( - os.path.basename(CLOUDINIT_NETPLAN_FILE) - ) + if not target: + file = os.path.basename(CLOUDINIT_NETPLAN_FILE) + else: + file = target + state_output_file._write_yaml_file(file) except Exception as e: LOG.warning( "Unable to render network config using netplan python module." @@ -392,7 +396,7 @@ def render_network_state( content = header + content netplan_config_changed = has_netplan_config_changed(fpnplan, content) - if not netplan_api_write_yaml_file(content): + if not netplan_api_write_yaml_file(content, target=fpnplan): fallback_write_netplan_yaml(fpnplan, content) if self.clean_default: diff --git a/packages/bddeb b/packages/bddeb index 4e06378c773..2fbb1cca3ca 100755 --- a/packages/bddeb +++ b/packages/bddeb @@ -306,7 +306,7 @@ def main(): "release_suffix": get_release_suffix(args.release), } - with temp_utils.tempdir() as tdir: + with temp_utils.tempdir(needs_exe=True) as tdir: # output like 0.7.6-1022-g36e92d3 ver_data = read_version()