Static network config bug in Amazon Linux on-prem vmware

0

Hi,
I’ve discovered a problem with static network configuration on Amazon Linux that is present in a few current releases. I’ve experienced this problem running Amazon Linux locally on vmware.

The problem is Amazon Linux never configures network and always stays on DHCP. I did some debugging and found the problem.

Function available() in sysconfig.py

Calling: util.system_info()
{'dist': ('amzn', '2', ''), 'uname': ('Linux', 'hostname', '4.14.198-152.320.amzn2.x86_64', '#1 SMP Wed Sep 23 23:57:28 UTC 2020', 'x86_64', 'x86_64'), 'python': '2.7.18', 'variant': 'linux', 'system': 'Linux', 'platform': 'Linux-4.14.198-152.320.amzn2.x86_64-x86_64-with-glibc2.2.5', 'release': '4.14.198-152.320.amzn2.x86_64'}

and util.system_info() 'variant' returns:
'linux'

this is not present in KNOWN_DISTRIBUTIONS:
'centos', 'fedora', 'rhel', 'suse'

cloud-init won't find sysconfig and return
cloud-init 19657: stages.py ERROR: Unable to render networking. Network config is likely broken: No available network renderers found. Searched through list: 'eni', 'sysconfig', 'netplan'

Here's a link to the full line:
https://github.com/canonical/cloud-init/blob/f99d4f96b00a9cfec1c721d364cbfd728674e5dc/cloudinit/net/sysconfig.py#L932

I was able to fix this issue by adding 'amzn' to util.py where the distribution is translated to variant 'rhel' used later. Please find the patch attached at the header of this message.

asked 4 years ago932 views
6 Answers
0

Hello,
Thanks for the feedback and the patch. I believe I understand the issue. One thing I wanted to make sure of is, what do you have set in your user-data for the VM? Below is an example of the options for a static configuration in the user-data for cloud-init:

network:
  version: 1
  config:
    - type: physical
      name: interface0
      mac_address: 00:11:22:33:44:55
      subnets:
         - type: static
           address: 192.168.23.14/24
           gateway: 192.168.23.1

For the rendering, it should be able to use sysconfig to make the network configuration. What version of cloud-init are you using on your VM?

-Heath

AWS
answered 4 years ago
0

Hi Heath,
thanks for your answer. Our user-data contains only 'users' info and 'write_files' keys and meta-data contains just the static network config.
Both configs are written exactly as described in this guide:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html

$ cloud-init -v
/usr/bin/cloud-init 19.3-3.amzn2

$ dmesg | head -1
0.000000 Linux version 4.14.200-155.322.amzn2.x86_64 (mockbuild@ip-10-0-1-230) (gcc version 7.3.1 20180712 (Red Hat 7.3.1-10) (GCC)) #1 SMP Thu Oct 15 20:11:12 UTC 2020

This problem is also present in earlier versions of cloud-init.

answered 4 years ago
0

I see the same issue with both the latest image (2.0.20200917.0) and 2.0.20200722.0. I don't have access to previous images to test. Not sure if it matters, but I am specifically using the KVM variant.

Are you suggesting that the documentation is out of date and that you now have to include the follow for a static IP config?

network:
version: 1
config:
- type: physical
name: interface0
mac_address: 00:11:22:33:44:55
subnets:
- type: static
address: 192.168.23.14/24
gateway: 192.168.23.1

profile picture
answered 4 years ago
0

Just piping in to mention I have the same issue. I've tried the simple setup in the meta-data file as described in the AWS documentation and I've tried a seperate setup using the approach you describe (using a "network-config" file instead of the user-data"). Both end up at the same "Unable to render networking" error in the cloud-init-output.log file.

The workaround in utils.py mentioned would probably solve it but that means we either have to edit the Amazon VDI with every new version or set up some unconventional scripting to allow our cloud-init script to complete on first boot.

Edited by: markotting on Dec 9, 2020 6:54 AM

answered 3 years ago
0

Thanks a lot - the error is gone after applying the patch and I can tell the file is applied noticing the hostname changed. But the IP config in this metadata file was not applied. Any idea?

$ more metadata.yaml
#cloud-config
local-hostname: uitlal2t04.mcs.company.com
network-interfaces: |
auto eth0
iface eth0 inet static
address 10.1.38.28
network 10.1.38.0
netmask 255.255.255.0
broadcast 10.1.38.255
gateway 10.1.38.254

I am using vmwareguestinfo data source

answered 3 years ago
0

How are you able to apply the patch at boot time? I'm stuck trying to figure out how to boot the image with seed.iso and get a patched cloud-init version. I've got some automation to create vm's in hyper-v using this pattern but the workflow is broken since the network interfaces can't get configured.

This is sadly still broken with the latest 2.0.20210126.0 release.

The documentation in the README.cloud-init is broken, as is the document here:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html

wynnw
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions