foreman icon indicating copy to clipboard operation
foreman copied to clipboard

pressed netplan provisioning template should treat no subnet consistently with finished template

Open damonmaria opened this issue 2 years ago • 8 comments

fixes #36181 - pressed netplan provisioning template should treat no subnet consistently with finished template

This changes the netplan setup to output dhcp4: true if there is no ipv4 subnet. This matches how the preseed finished template does it and is IMHO correct.

I have not changed how :dhcp6 is calculated. If the same change was applied there then the netplan would for have dhcp6: true on networks that probably don't want to use ipv6. And anyway, I do not have an ipv6 network on which to test and therefore don't want to change how that works.

NOTE: I suspect there is another bug in the preseed_netplan_setup.erb template in that all the checks for the :dhcp6 parameter look like the following:

:dhcp6 => bond.subnet6.nil? ? false : bond.subnet.dhcp_boot_mode?

I think the second reference to .subnet should be .subnet6 like the first.

damonmaria avatar Mar 08 '23 02:03 damonmaria

Can one of the admins verify this patch?

theforeman-bot avatar Mar 08 '23 02:03 theforeman-bot

Can one of the admins verify this patch?

theforeman-bot avatar Mar 08 '23 02:03 theforeman-bot

Can one of the admins verify this patch?

theforeman-bot avatar Mar 08 '23 02:03 theforeman-bot

This changes the netplan setup to output dhcp4: true if there is no ipv4 subnet. This matches how the preseed finished template does it and is IMHO correct.

I wonder why you think this is correct. If there is no IPv4 subnet, that implies you want IPv6 only. How do you imagine that you configure IPv6-only after your patch would be merged?

I think the second reference to .subnet should be .subnet6 like the first.

That does look like a bug indeed.

ekohl avatar Mar 20 '23 12:03 ekohl

@ekohl We use the bootdisk plugin to provision servers into networks that we don't control. So have in the past have not assigned subnets to our hosts. The existing preseed templates all interpret no subnets to implicitly mean dhcp. See the following examples:

  • https://github.com/theforeman/foreman/blob/3305096ae310c9851fc2e17591f9a2579d80db8d/app/views/unattended/provisioning_templates/provision/preseed_default.erb#L49-L50
  • https://github.com/theforeman/foreman/blob/3305096ae310c9851fc2e17591f9a2579d80db8d/app/views/unattended/provisioning_templates/finish/preseed_default_finish.erb#L24-L25
  • https://github.com/theforeman/foreman/blob/3305096ae310c9851fc2e17591f9a2579d80db8d/app/views/unattended/provisioning_templates/snippet/preseed_networking_setup.erb#L12

But I do agree that this in somewhat magical and inobvious.

Given our circumstances now I can work around this... however, I'm not sure if others are relying on this implicit functionality. I'm happy to close this PR.

damonmaria avatar Mar 20 '23 22:03 damonmaria

Interesting. At least looking at the last one I think the template is incomplete. If there is no IPv4 subnet at all, I think it should not output any config like iface $real inet MODE. Or in other words, it should be possible to generate:

auto $real
allow-hotplug $real
iface $real inet6 dhcp

Note inet6 dhcp, not inet. Today it's not possible.

I think this is one of those tricky situations where there are multiple ways to interpret something. Foreman should have a common way of translating its network config provisioning templates.

@stejskalleos is starting to take care of this area, but currently traveling. Perhaps we can wait until he's back so he has a chance to weigh in?

ekohl avatar Mar 20 '23 22:03 ekohl

Can you please rework/rebase this PR @damonmaria ?

sbernhard avatar Nov 03 '23 08:11 sbernhard

Can you please rework/rebase this PR @damonmaria ?

Which particular change are you referring to?

In the discussion above on this issue it was agreed with @ekohl not to propagate this functionality further, even though most existing templates aim for it.

If you're referring to the bond.subnet6 / bond.subnet bug then that should probably be a separate PR.

damonmaria avatar Nov 04 '23 01:11 damonmaria