Open regner opened 4 years ago
Hello,
Can you share the cloud config drive format (aka what metadata type is loaded by cloudbase-init)? Is it NoCloud? I will use this information to see how cloud-init implements it so that we can have a mirrored implementation.
Also, if you could share the metadata files from the metadata ISO attached by proxmox, that would be great.
Thank you.
It is probable that cloud-init does not use the debiface network config, but a more advanced one from the metadata (I need the metadata files from the config drive ISO to confirm this). If that is the case, the cloudbase-init logs would be required too, to check why the advanced version was not used.
For metadata we are using: cloudbaseinit.metadata.services.configdrive.ConfigDriveService
Here is the contents of OPENSTAT/LATEST/META_DATA.JSON
:
{
"uuid": "eed9becb0af80e83116020a37066cf04dd212e05",
"network_config": { "content_path": "/content/0000" }
}
Here are the contents of OPENSTACK/LATEST/USER_DATA
:
#cloud-config
hostname: something
manage_etc_hosts: true
chpasswd:
expire: False
users:
- default
package_upgrade: true
For metadata we are using:
cloudbaseinit.metadata.services.configdrive.ConfigDriveService
Here is the contents of
OPENSTAT/LATEST/META_DATA.JSON
:{ "uuid": "eed9becb0af80e83116020a37066cf04dd212e05", "network_config": { "content_path": "/content/0000" } }
Here are the contents of
OPENSTACK/LATEST/USER_DATA
:#cloud-config hostname: something manage_etc_hosts: true chpasswd: expire: False users: - default package_upgrade: true
Hello,
Can you share the openstack/latest/content/0000? A quick fix would be to add an OR to the regexp here, https://github.com/cloudbase/cloudbase-init/blob/master/cloudbaseinit/utils/debiface.py#L56.
r"(dns-nameservers\s+)|(dns_nameservers\s+)|(dns-nameserver\s+)|(dns_nameserver\s+)(?P<dnsnameservers>.+)"
Can you try the regexp above?
EDIT: the above regexp works only for dns_nameserver case.
Thank you, Adrian Vladu
Correct regexp:
r"(dns-nameservers|dns_nameservers|dns-nameserver|dns_nameserver)\s+(?P<dnsnameservers>.+)"
Any update on this?
same issue :(
Same problem with Proxmox 6.4-4
Here is content of OPENSTACK/CONTENT/0000
auto lo
iface lo inet loopback
dns_nameservers 192.168.0.2
dns_search local
auto eth0
iface eth0 inet static
address 192.168.66.71
netmask 255.255.255.0
gateway 192.168.66.254
It generated by configdrive2_network
After applying proposed changes I get this in logs:
2021-12-06 16:12:26.591 4208 INFO cloudbaseinit.utils.debiface [-] Parsing Debian config...
auto lo
iface lo inet loopback
dns_nameservers 192.168.0.2
dns_search local
auto eth0
iface eth0 inet static
address 192.168.66.71
netmask 255.255.255.0
gateway 192.168.66.254
2021-12-06 16:12:26.591 4208 DEBUG cloudbaseinit.utils.debiface [-] Found new interface: {'name': None, 'mac': None, 'address': None, 'address6': None, 'netmask': None, 'netmask6': None, 'broadcast': None, 'gateway': None, 'gateway6': None, 'dnsnameservers': ['192.168.0.2']} _add_nic C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\lib\site-packages\cloudbaseinit\utils\debiface.py:104
2021-12-06 16:12:26.591 4208 DEBUG cloudbaseinit.utils.debiface [-] Found new interface: {'name': 'eth0', 'mac': None, 'address': '192.168.66.71', 'address6': None, 'netmask': '255.255.255.0', 'netmask6': None, 'broadcast': None, 'gateway': '192.168.66.254', 'gateway6': None, 'dnsnameservers': None} _add_nic C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\lib\site-packages\cloudbaseinit\utils\debiface.py:104
No dns nameservers configured.
Switching to 'nocloud' is also not possible, as proxmox generating ISO without joliet-long extension, and file meta-data
has name META_DATA
instead.
For someone who want to make it work with proxmox:
diff --git a/cloudbaseinit/plugins/common/networkconfig.py b/cloudbaseinit/plugins/common/networkconfig.py
index 8704721..9aa995c 100644
--- a/cloudbaseinit/plugins/common/networkconfig.py
+++ b/cloudbaseinit/plugins/common/networkconfig.py
@@ -57,6 +57,15 @@ def _preprocess_nics(network_details, network_adapters):
if not network_adapters:
raise exception.CloudbaseInitException(
"no network adapters available")
+
+ #Proxmox compatibility, "dnsnameservers" is present only in lo interface details
+ default_nameservers = None
+ for nic in network_details:
+ if None == getattr(nic, "name", None):
+ default_nameservers = getattr(nic, "dnsnameservers", None)
+ if default_nameservers:
+ break
+
# Sort VM adapters by name (assuming that those
# from the context are in correct order).
# Do this for a better matching by order
@@ -115,7 +124,7 @@ def _preprocess_nics(network_details, network_adapters):
nic.broadcast,
nic.gateway,
nic.gateway6,
- nic.dnsnameservers
+ nic.dnsnameservers or default_nameservers
)
refined_network_details.append(nic)
return refined_network_details
diff --git a/cloudbaseinit/utils/debiface.py b/cloudbaseinit/utils/debiface.py
index 4c4c26a..37d4c34 100644
--- a/cloudbaseinit/utils/debiface.py
+++ b/cloudbaseinit/utils/debiface.py
@@ -53,7 +53,7 @@ FIELDS = {
r"(?P<{}>\S+)".format(GATEWAY)),
GATEWAY6: re.compile(r"post-up ip -6 route add default via "
r"(?P<{}>.+) dev".format(GATEWAY6)),
- DNSNS: re.compile(r"dns-nameservers\s+(?P<{}>.+)".format(DNSNS))
+ DNSNS: re.compile(r"(dns-nameservers|dns_nameservers|dns-nameserver|dns_nameserver)\s+(?P<{}>.+)".format(DNSNS))
}
IFACE_TEMPLATE = dict.fromkeys(FIELDS.keys())
# Map IPv6 availability by value index under `NetworkDetails`.
Not sure that it will be applied to cloudbase-init, probably it should be fixed in proxmox with moving to nocloud
.
When using Proxmox the config that is generated for cloud-init has the DNS server key as "dns_nameserver" but the network plugin expects it to be "dns-nameserver".
I don't know cloudinit like, at all really, so I don't know if the standard allows both or what. I know the cloudinit config works for our Ubuntu images which makes me lean towards the standard, or at least the normal implementation of it, works with either.
I believe this is the responsible regex causing the issue: https://github.com/cloudbase/cloudbase-init/blob/master/cloudbaseinit/utils/debiface.py#L56