1

Issue:

I'm trying to use packer to create an Ubuntu Server 22.04 image and I'm running into issues when it comes to renaming the NIC using a valid netplan config and then also installing one package.

A couple things to note on the background:

  1. I'm renaming the NIC because I'm trying to use terraform to set the NIC config on startup using proxmox with cloud-init. When cloud-init runs on the cloned image it seems to want to rename the NIC on first boot and since it cannot rename the NIC (to eth0 from ens18) on the fly it takes a second reboot before cloud-init sets the proper IP address on the VM. This is less than ideal when I want to be able to spin an ubuntu server up with terraform since it takes a manual reboot.

I've had no issues with Proxmox and cloud-init drive/config settings it provides for the following OS's:

  • AlmaLinux 8 & 9
  • RHEL 7, 8, & 9
  • Windows Server 2012, 2016, 2019, and 2022 (Cloudbase-init)

They all just seem to accept the cloud-init config that terraform sends over to proxmox to use and all is good to go. All this to say that maybe proxmox shouldn't be renaming the NIC, but Ubuntu Server is the first OS I've had issues with this on and I'm not really looking for a solution anywhere besides Ubuntu currently.

  1. I need to install qemu-guest-agent on the VM so that packer is able to read in the IP address from the Proxmox API so it knows who to connect to.

Specifics:

  1. I can install qemu-guest-agent if I don't specify any network settings and let subiquity/netplan provide the defaults. When I do this, the final autoinstall-user-data located in /var/log/installer on a successful autoinstall shows the following network and packages config:
autoinstall:
<snipped>
  network:
    ethernets:
      ens18:
        dhcp4: true
    version: 2
  packages:
  - qemu-guest-agent
<snipped>
  1. I can successfully rename the NIC using subiquity/netplan. When this is done, it fails to install qemu-guest-agent and fails the build process. Here's the config I use for that:
  network:
    ethernets:
      ens18:
        match:
          driver: e1000
        dhcp4: true
        set-name: eth0
    version: 2
  packages:
  - qemu-guest-agent

The above network: block does successfully rename the NIC to eth0 AND I have full networking on the broken install. I'm able to ping something such as google.com and am also able to SSH into the machine. I can see from the logs that the rename is successful and I can verify the new NIC name on the failed install when it pops me into a shell.

Below are the errors this then runs into after the NIC rename.

From subiquity-server-debug.log.1976:

2022-09-04 07:21:30,557 DEBUG root:39 start: subiquity/Install/install/postinstall/install_qemu-guest-agent: installing qemu-guest-agent
2022-09-04 07:21:30,560 DEBUG subiquitycore.utils:112 astart_command called: ['systemd-run', '--wait', '--same-dir', '--property', 'SyslogIdentifier=subiquity_log.1976', '--setenv', 'PATH=/snap/subiquity/3698/bin:/snap/subiquity/3698/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/3698/bin', '--setenv', 'PYTHONPATH=:/snap/subiquity/3698/lib/python3.8/site-packages', '--setenv', 'PYTHON=/snap/subiquity/3698/usr/bin/python3.8', '--setenv', 'SNAP=/snap/subiquity/3698', '--', '/snap/subiquity/3698/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1976.5"}}', 'system-install', '-t', '/target', '--', 'qemu-guest-agent']
2022-09-04 07:21:30,570 INFO root:39 start: subiquity/Meta/status_GET: 
2022-09-04 07:21:31,706 DEBUG root:39 start: subiquity/Install/install/postinstall/install_qemu-guest-agent/cmd-system-install: curtin command system-install
2022-09-04 07:21:31,826 ERROR root:39 finish: subiquity/Install/install/postinstall/install_qemu-guest-agent: FAIL: Command '['systemd-run', '--wait', '--same-dir', '--property', 'SyslogIdentifier=subiquity_log.1976', '--setenv', 'PATH=/snap/subiquity/3698/bin:/snap/subiquity/3698/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/3698/bin', '--setenv', 'PYTHONPATH=:/snap/subiquity/3698/lib/python3.8/site-packages', '--setenv', 'PYTHON=/snap/subiquity/3698/usr/bin/python3.8', '--setenv', 'SNAP=/snap/subiquity/3698', '--', '/snap/subiquity/3698/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1976.5"}}', 'system-install', '-t', '/target', '--', 'qemu-guest-agent']' returned non-zero exit status 100.
2022-09-04 07:21:31,833 ERROR root:39 finish: subiquity/Install/install/postinstall: FAIL: Command '['systemd-run', '--wait', '--same-dir', '--property', 'SyslogIdentifier=subiquity_log.1976', '--setenv', 'PATH=/snap/subiquity/3698/bin:/snap/subiquity/3698/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/3698/bin', '--setenv', 'PYTHONPATH=:/snap/subiquity/3698/lib/python3.8/site-packages', '--setenv', 'PYTHON=/snap/subiquity/3698/usr/bin/python3.8', '--setenv', 'SNAP=/snap/subiquity/3698', '--', '/snap/subiquity/3698/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1976.5"}}', 'system-install', '-t', '/target', '--', 'qemu-guest-agent']' returned non-zero exit status 100.
2022-09-04 07:21:31,834 DEBUG subiquitycore.common.errorreport:384 generating crash report
2022-09-04 07:21:31,872 INFO subiquitycore.common.errorreport:406 saving crash report 'install failed crashed with CalledProcessError' to /var/crash/1662276091.834314585.install_fail.crash
2022-09-04 07:21:31,873 ERROR root:39 finish: subiquity/Install/install: FAIL: Command '['systemd-run', '--wait', '--same-dir', '--property', 'SyslogIdentifier=subiquity_log.1976', '--setenv', 'PATH=/snap/subiquity/3698/bin:/snap/subiquity/3698/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/3698/bin', '--setenv', 'PYTHONPATH=:/snap/subiquity/3698/lib/python3.8/site-packages', '--setenv', 'PYTHON=/snap/subiquity/3698/usr/bin/python3.8', '--setenv', 'SNAP=/snap/subiquity/3698', '--', '/snap/subiquity/3698/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1976.5"}}', 'system-install', '-t', '/target', '--', 'qemu-guest-agent']' returned non-zero exit status 100.
2022-09-04 07:21:31,875 INFO root:39 start: subiquity/ErrorReporter/1662276091.834314585.install_fail/add_info: 
2022-09-04 07:21:31,876 ERROR subiquity.server.server:416 top level error
Traceback (most recent call last):
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/controllers/cmdlist.py", line 104, in _run
    await Install.install_task
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquitycore/context.py", line 148, in decorated_async
    return await meth(self, **kw)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/controllers/install.py", line 177, in install
    await self.postinstall(context=context)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquitycore/context.py", line 148, in decorated_async
    return await meth(self, **kw)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/controllers/install.py", line 200, in postinstall
    await self.install_package(context=context, package=package)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquitycore/context.py", line 148, in decorated_async
    return await meth(self, **kw)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/controllers/install.py", line 227, in install_package
    await run_curtin_command(
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/curtin.py", line 181, in run_curtin_command
    return await cmd.wait()
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/curtin.py", line 118, in wait
    result = await self.runner.wait(self.proc)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/runner.py", line 81, in wait
    raise subprocess.CalledProcessError(proc.returncode, proc.args)
subprocess.CalledProcessError: Command '['systemd-run', '--wait', '--same-dir', '--property', 'SyslogIdentifier=subiquity_log.1976', '--setenv', 'PATH=/snap/subiquity/3698/bin:/snap/subiquity/3698/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/3698/bin', '--setenv', 'PYTHONPATH=:/snap/subiquity/3698/lib/python3.8/site-packages', '--setenv', 'PYTHON=/snap/subiquity/3698/usr/bin/python3.8', '--setenv', 'SNAP=/snap/subiquity/3698', '--', '/snap/subiquity/3698/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1976.5"}}', 'system-install', '-t', '/target', '--', 'qemu-guest-agent']' returned non-zero exit status 100.
2022-09-04 07:21:31,877 ERROR subiquity.server.server:416 top level error
Traceback (most recent call last):
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/controllers/shutdown.py", line 77, in _wait_install
    await self.app.controllers.Install.install_task
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/controllers/cmdlist.py", line 104, in _run
    await Install.install_task
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquitycore/context.py", line 148, in decorated_async
    return await meth(self, **kw)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/controllers/install.py", line 177, in install
    await self.postinstall(context=context)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquitycore/context.py", line 148, in decorated_async
    return await meth(self, **kw)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/controllers/install.py", line 200, in postinstall
    await self.install_package(context=context, package=package)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquitycore/context.py", line 148, in decorated_async
    return await meth(self, **kw)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/controllers/install.py", line 227, in install_package
    await run_curtin_command(
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/curtin.py", line 181, in run_curtin_command
    return await cmd.wait()
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/curtin.py", line 118, in wait
    result = await self.runner.wait(self.proc)
  File "/snap/subiquity/3698/lib/python3.8/site-packages/subiquity/server/runner.py", line 81, in wait
    raise subprocess.CalledProcessError(proc.returncode, proc.args)
subprocess.CalledProcessError: Command '['systemd-run', '--wait', '--same-dir', '--property', 'SyslogIdentifier=subiquity_log.1976', '--setenv', 'PATH=/snap/subiquity/3698/bin:/snap/subiquity/3698/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/3698/bin', '--setenv', 'PYTHONPATH=:/snap/subiquity/3698/lib/python3.8/site-packages', '--setenv', 'PYTHON=/snap/subiquity/3698/usr/bin/python3.8', '--setenv', 'SNAP=/snap/subiquity/3698', '--', '/snap/subiquity/3698/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1976.5"}}', 'system-install', '-t', '/target', '--', 'qemu-guest-agent']' returned non-zero exit status 100.
2022-09-04 07:21:32,072 ERROR root:39 finish: subiquity/Install/install/postinstall/install_qemu-guest-agent/cmd-system-install: FAIL: curtin command system-install
2022-09-04 07:21:32,594 INFO root:39 finish: subiquity/ErrorReporter/1662276091.834314585.install_fail/add_info: SUCCESS: written to /var/crash/1662276091.834314585.install_fail.crash
2022-09-04 07:21:32,596 INFO root:39 finish: subiquity/Meta/status_GET: SUCCESS: 200 {"state": "ERROR", "confirming_tty": "", "error": {"state": "DONE", "base": "...
2022-09-04 07:21:32,599 INFO aiohttp.access:233  [04/Sep/2022:07:21:30 +0000] "GET /meta/status?cur=%22POST_RUNNING%22 HTTP/1.1" 200 524 "-" "Python/3.8 aiohttp/3.6.2"

If I run the command from the failed logs manually: systemd-run --wait --same-dir --property SyslogIdentifier=subiquity_log.1976 --setenv PATH=/snap/subiquity/3698/bin:/snap/subiquity/3698/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/3698/bin --setenv PYTHONPATH=:/snap/subiquity/3698/lib/python3.8/site-packages --setenv PYTHON=/snap/subiquity/3698/usr/bin/python3.8 --setenv SNAP=/snap/subiquity/3698 -- /snap/subiquity/3698/usr/bin/python3.8 -m curtin --showtrace -vvvvvv --set json:reporting='{"subiquity": {"type": "journald", "identifier": "curtin_event.1976.5"}}' system-install -t /target -- qemu-guest-agent

I can see the following in syslog:

Sep  4 07:31:18 ubuntu-server systemd[1]: Started /snap/subiquity/3698/usr/bin/python3.8 -m curtin --showtrace -vvvvvv --set json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1976.5"}} system-install -t /target -- qemu-guest-agent.
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: start: cmd-system-install: curtin command system-install
Sep  4 07:31:19 ubuntu-server curtin_event.1976.5[16331]: start: cmd-system-install: curtin command system-install
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['mount', '--bind', '/dev', '/target/dev'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['mount', '--bind', '/proc', '/target/proc'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['mount', '--bind', '/run', '/target/run'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['mount', '--bind', '/sys', '/target/sys'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['unshare', '--help'] with allowed return codes [0] (capture=True)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/target', 'eatmydata', 'apt-get', '--quiet', '--assume-yes', '--option=Dpkg::options::=--force-unsafe-io', '--option=Dpkg::Options::=--force-confold', 'install', 'qemu-guest-agent'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16342]: Reading package lists...
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16342]: Building dependency tree...
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16342]: Reading state information...
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16342]: E: Unable to locate package qemu-guest-agent
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['udevadm', 'settle'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: TIMED subp(['udevadm', 'settle']): 0.028
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['mount', '--make-private', '/target/sys'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['umount', '/target/sys'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['mount', '--make-private', '/target/run'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server systemd[1]: target-sys.mount: Deactivated successfully.
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['umount', '/target/run'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['mount', '--make-private', '/target/proc'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['umount', '/target/proc'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['mount', '--make-private', '/target/dev'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Running command ['umount', '/target/dev'] with allowed return codes [0] (capture=False)
Sep  4 07:31:19 ubuntu-server subiquity_event.1976[1976]:       subiquity/Install/install/postinstall/install_qemu-guest-agent/cmd-system-install: curtin command system-install
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: system install failed for ['qemu-guest-agent']: Unexpected error while running command.
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/target', 'eatmydata', 'apt-get', '--quiet', '--assume-yes', '--option=Dpkg::options::=--force-unsafe-io', '--option=Dpkg::Options::=--force-confold', 'install', 'qemu-guest-agent']
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Exit code: 100
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Reason: -
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Stdout: ''
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: Stderr: ''
Sep  4 07:31:19 ubuntu-server subiquity_log.1976[16331]: finish: cmd-system-install: FAIL: curtin command system-install
Sep  4 07:31:19 ubuntu-server curtin_event.1976.5[16331]: finish: cmd-system-install: FAIL: curtin command system-install
Sep  4 07:31:19 ubuntu-server systemd[1]: run-u70.service: Main process exited, code=exited, status=100/n/a
Sep  4 07:31:19 ubuntu-server systemd[1]: run-u70.service: Failed with result 'exit-code'.
Sep  4 07:31:19 ubuntu-server systemd[1]: run-u70.service: Consumed 1.595s CPU time.
Sep  4 07:31:20 ubuntu-server subiquity_event.1976[1976]:       subiquity/Install/install/postinstall/install_qemu-guest-agent/cmd-system-install: curtin command system-install
Sep  4 07:31:20 ubuntu-server systemd[1]: target-run.mount: Deactivated successfully.
Sep  4 07:31:20 ubuntu-server systemd[1]: target-proc.mount: Deactivated successfully.
Sep  4 07:31:20 ubuntu-server systemd[1]: target-dev.mount: Deactivated successfully.

This same step/config is successful when ran on an autoinstall without renaming the NIC:

2022-09-01 23:11:45,679 DEBUG root:39 start: subiquity/Install/install/postinstall/install_qemu-guest-agent: installing qemu-guest-agent
2022-09-01 23:11:45,988 DEBUG subiquitycore.utils:112 astart_command called: ['systemd-run', '--wait', '--same-dir', '--property', 'SyslogIdentifier=subiquity_log.1972', '--setenv', 'PATH=/snap/subiquity/3698/bin:/snap/subiquity/3698/usr/bin:/usr/local/s
bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/3698/bin', '--setenv', 'PYTHONPATH=:/snap/subiquity/3698/lib/python3.8/site-packages', '--setenv', 'PYTHON=/snap/subiquity/3698/usr/bin/python3.8', '--
setenv', 'SNAP=/snap/subiquity/3698', '--', '/snap/subiquity/3698/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1972.5"}}', 'system-install', '-t', '/tar
get', '--', 'qemu-guest-agent']
2022-09-01 23:11:46,031 INFO root:39 start: subiquity/Meta/status_GET:
2022-09-01 23:11:47,706 DEBUG root:39 start: subiquity/Install/install/postinstall/install_qemu-guest-agent/cmd-system-install: curtin command system-install
2022-09-01 23:11:56,394 DEBUG subiquity.server.curtin:123 waited 0.1 seconds for events to drain
2022-09-01 23:11:56,458 DEBUG root:39 finish: subiquity/Install/install/postinstall/install_qemu-guest-agent/cmd-system-install: SUCCESS: curtin command system-install
2022-09-01 23:11:56,496 DEBUG subiquity.server.curtin:123 waited 0.2 seconds for events to drain
2022-09-01 23:11:56,497 DEBUG root:39 finish: subiquity/Install/install/postinstall/install_qemu-guest-agent: SUCCESS: installing qemu-guest-agent

At this point I'm not too sure why it states it's not able to locate the package after the NIC is renamed. I'm a bit stumped at this point because the VM does have full internet access after I'm presented the shell.

Any sort of help/troubleshooting steps are appreciated. Happy to provide any info I can.

  • Hey can you share your whole packer config I have this issue and it seems like its not going to be solved! – hamed May 21 '23 at 06:36

3 Answers3

3

I like to configure networking using late-commands.

#cloud-config
autoinstall:
  late-commands:
    - |
      rm /target/etc/netplan/00-installer-config.yaml
      cat <<EOF > /target/etc/netplan/80-my.yaml
      network:
        ethernets:
          ens18:
            match:
              driver: e1000
            dhcp4: true
            set-name: eth0
        version: 2
      EOF

how it works

If there is no network configuration block in your user-data file then the installer (subiquity) will use a generic netplan config. Later, subiquity will generate a netplan config for the installed system and will also use it for the installer environment. In late-commands you can delete the subiquity generated config and replace it with whatever you want. This will only affect the installed system.

links

0

I wanted to add some more info for anyone else who may run into similar issues. My main post is incorrect in some areas now that I've resolved my issues and know what was wrong.

First off, Andrew's answer will resolve the issue asked in the post. But I did figure out why my cloud-init wasn't kicking off with the help of his post.

Something in the cloud-init logs I was originally looking at lead me to think the NIC wasn't able to be renamed with cloud-init and which is why I was looking to rename the NIC and ran into all these issues. But this is wrong.

Once I booted the clone with Andrew's config and the NIC was renamed I realized it was always pulling a DHCP config even after successive reboots. After digging into that some more I realized that cloud-init does interact with netplan (which is why it differs from all the other OS's I listed).

I found this happening with cloud-init showing it interacts with netplan in some instances:

Sep  6 00:23:13 ubuntu22 cloud-init[773]: 2022-09-06 00:23:08,634 - util.py[DEBUG]: Writing to /etc/netplan/50-cloud-init.yaml - wb: [644] 695 bytes
Sep  6 00:23:13 ubuntu22 cloud-init[773]: 2022-09-06 00:23:08,636 - subp.py[DEBUG]: Running command ['netplan', 'generate'] with allowed return codes [0] (shell=False, capture=True)
Sep  6 00:23:13 ubuntu22 cloud-init[773]: 2022-09-06 00:23:09,030 - subp.py[DEBUG]: Running command ['udevadm', 'test-builtin', 'net_setup_link', '/sys/class/net/eth0'] with allowed return codes [0] (shell=False, capture=True)
Sep  6 00:23:13 ubuntu22 cloud-init[773]: 2022-09-06 00:23:09,049 - subp.py[DEBUG]: Running command ['udevadm', 'test-builtin', 'net_setup_link', '/sys/class/net/lo'] with allowed return codes [0] (shell=False, capture=True)

So to allow cloud-init to properly setup the network config I ended up needing to remove the built in installer netplan config and reinstall/cleanup cloud-init. Below are my the steps I use with ansible for this:

    - name: Run cloud-init clean
      ansible.builtin.shell: cloud-init clean
      when: ansible_distribution == "Ubuntu"
- name: Remove cloud-init
  ansible.builtin.apt:
    name: cloud-init
    state: absent
  when: ansible_distribution == &quot;Ubuntu&quot;

- name: Remove /etc/cloud
  ansible.builtin.shell: rm -rf /etc/cloud
  when: ansible_distribution == &quot;Ubuntu&quot;

- name: Remove /var/lib/cloud
  ansible.builtin.shell: rm -rf /var/lib/cloud
  when: ansible_distribution == &quot;Ubuntu&quot;

- name: Reboot the Ubuntu VM
  ansible.builtin.reboot:
  when: ansible_distribution == &quot;Ubuntu&quot;

- name: Install cloud-init
  ansible.builtin.apt:
    name: cloud-init
    state: latest
  when: ansible_distribution == &quot;Ubuntu&quot;

- name: Remove netplan file
  ansible.builtin.shell: rm -f /etc/netplan/00-installer-config.yaml
  when: ansible_distribution == &quot;Ubuntu&quot;
  ignore_errors: yes

And the above is accompanied by an autoinstall config that excludes the whole network: block I thought I needed (and so allowing subiquity to generate it).

  • This seems strange. cloud-init should not configure netplan on a system installed with subiquity. This is because subiquity will create the file /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg with the content network: {config: disabled} on the installed system. This is different than alternative systems like the cloud-images, which can depend on cloud-init to configure netplan. – Andrew Lowther Sep 06 '22 at 23:14
  • That's interesting! I did spin up another VM and found that file did exist. It's very possible that the cloud-init logs I used in this comment were from a time when I removed the cloud configs. I did a bit of troubleshooting trying to narrow down this issue and the above is what ends up working for me. More incorrect info from me then as I really have no idea what I'm doing with cloud-init. This is the first time I've had to really dig into it as most of the time it's just magic. – Tuxington Sep 08 '22 at 04:21
0
set timeout=10
if loadfont /boot/grub/fonts/font.pf2 ; then
        set gfxmode=auto
        insmod efi_gop
        insmod efi_uga
        insmod gfxterm
        terminal_output gfxterm
fi
# background_image /boot/grub/image/splash.png
set menu_color_normal=white/black
set menu_color_highlight=black/light-red

menuentry "Install Ubuntu" {
        set gfxpayload=keep
        linux   /casper/vmlinuz ip=dhcp cloud-config-url=/dev/null autoinstall ds="nocloud-net;s=http://xxx.xxx.xxx.xxx/autoinstall/" --- net.ifnames=0 biosdevname=0
        initrd  /casper/initrd
}
grub_platform
if [ "$grub_platform" = "efi" ]; then
menuentry 'Boot from next volume' {
        exit 1
}
menuentry 'UEFI Firmware Settings' {
        fwsetup
}
else
menuentry 'Test memory' {
        linux16 /boot/memtest86+.bin
}
fi

your ethernet card will be named eth0 with "net.ifnames=0 biosdevname=0" in the installation grub

Kalwin
  • 1