Provisioning Ubuntu 22.04 with multiple network interfaces - problem with deprecated gateway4 netplan property

When provisioning an Ubuntu 22.04 Host with multiple network interfaces, only the primary network interface is functional.

Expected outcome:
Additional specified network interfaces are present and functional after deployment.

Foreman and Proxy versions:

Foreman and Proxy plugin versions:

  • foreman-tasks: 9.0.1
  • foreman_ansible: 13.0.2
  • foreman_bootdisk: 21.2.1
  • foreman_remote_execution: 12.0.2
  • katello: 4.11.0

Distribution and version:
AlmaLinux 8.9

Other relevant data:
After provisioning, the additional network interface is present, but not working. I was able to get it working manually by fiddling with /etc/netplan/00-installer-config.yaml

The issue seems to be with the deprecated gateway4: property. Instead, the system wants a routes: property configured for each network interface.

I am not confident in my ability to modify the preseed_netplan_generic_interface provisioning template, to replace gateway4: with a properly configured routes:. Hopefully somebody else is already working on this, or can provide some advice/guidance?

Forgot to mention, there’s also an issue with the MAC address. It seems to take the MAC address of the first Network Interface, and put it into the match: property of the bottom interface. I think this is something else that needs to be fixed in preseed_netplan_generic_interface.

Do you know the required changes to the generated file?

If yes, you can probably reverse-engineer what needs to be changed and can do a PR on

If I understand correctly, the current state is:

<%-   if static_v4 && @subnet.gateway.present? -%>
        gateway4: <%= @subnet.gateway %>
<%-   end -%>
<%-   if static_v6 && @subnet6.gateway.present? -%>
        gateway6: "<%= @subnet6.gateway %>"
<%-   end -%>

And it has to be changed to something like this:

<%- if @interface.ip == @host.primary_interface.ip -%>
<%-   if (static_v4 && @subnet.gateway.present?) || (static_v6 && @subnet6.gateway.present?) -%>
<%-     if static_v4 && @subnet.gateway.present? -%>
        - to:
          via: <%= @subnet.gateway %>
<%-     end -%>
<%-     if static_v6 && @subnet6.gateway.present? -%>
        - to: ::/0
          via: "<%= @subnet6.gateway %>"
<%-     end -%>
<%-   end -%>
<%- end -%>

At least this is my understanding that the routes need only be set to the default routes for the primary interface.