canonical / canonical/cloud-init
[docs]: apply_network_config: false config is not effect
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 22
Description
Environment is such as:
> Cloud-init: v23.1.1
> platform: Azure
> OS: Rocky9.2
I need to set apply_network_config to false in config file: /etc/cloud/cloud.cfg, to disable change the way of create network config file(ifcfg-ethx), because when more than one ip in machine metadata,cloud-init in init-local step set other ip to static ip.
I change config first, such as
```shell
cat /etc/cloud/cloud.cfg
# .....
datasource:
Azure:
apply_network_config: false
```
then reboot virtual machine, I find it is not effect, I can find message from log, this log is added by myself
```shell
DataSourceAzure.py[DEBUG]: debug ds_cfg :{'data_dir': '/var/lib/waagent', 'disk_aliases': {'ephemeral0': '/dev/disk/cloud/azure_resource'}, 'apply_network_config': True}
......
handlers.py[DEBUG]: finish: azure-ds/generate_network_config_from_instance_network_metadata: SUCCESS: generate_network_config_from_instance_network_metadata
```
but I alse can see the config is loaded by program,
```shell
2024-03-08 07:35:45,046 - stages.py[DEBUG]: debug _cfg: {'datasource_list': ['Azure', 'None'], 'datasource': {'Azure': {'apply_network_config': False}}......
```
I add some debug code in DataSourceAzure.py file
```python
@azure_ds_telemetry_reporter
def _generate_network_config(self):
"""Generate network configuration according to configuration."""
# Use IMDS network metadata, if configured.
LOG.debug("debug _metadata_imds :%s",self._metadata_imds)
LOG.debug("debug ds_cfg :%s",self.ds_cfg)
if (
self._metadata_imds
and self._metadata_imds != sources.UNSET
and self.ds_cfg.get("apply_network_config")
):
try:
return generate_network_config_from_instance_network_metadata(
self._metadata_imds["network"]
)
except Exception as e:
LOG.error(
"Failed generating network config "
"from IMDS network metadata: %s",
str(e),
)
# Generate fallback configuration.
try:
return _generate_network_config_from_fallback_config()
except Exception as e:
LOG.error("Failed generating fallback network config: %s", str(e))
```
as you see, I want cloud-init generate network config content from _generate_network_config_from_fallback_config function, but the apply_network_config: false is not effect
Contributor guide
Assessment
This issue has not been assessed yet.