michaelrigart / ansible-role-interfaces

An ansible role for configuring different network interfaces
GNU General Public License v3.0
83 stars 61 forks source link

Add support for managing loopback devices with Network Manager #162

Open Aethylred opened 2 weeks ago

Aethylred commented 2 weeks ago

Network Manager now supports managing and creating loopback devices, can we add support for this feature to the role?

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1332

https://access.redhat.com/solutions/2108251

I'll be making a pull request soon as I think this can be done just by modifying the ethernet_nmconnection.j2 template as only those distributions that will use this template will support this feature.

An example where we're adding a route to the loopback device for a HAproxy would look like this:

interfaces_ether_interfaces:
  - device: lo
    type: loopback
    bootproto: dhcp
    route:
      # equvalent to "ip route add local 0.0.0.0/0 dev lo table 100"
      - table: 100
        device: lo
        network: 0.0.0.0
        netmask: 0
        options:
         - type: local

Note the bootproto is required to set method=auto in the nmconnection file.

Aethylred commented 2 weeks ago

This mostly works, but I'm having some issues with missing entries and I'm looking at figuring them out. This seems to need the empty [loopback] and [proxy] sections, as well as the uuid in the [connection] section and addr-gen-mode=default in the [ipv6] section.

Can't do this with a lineinfile either as the required lo.nmconnect file is not created by default. I think the current approach is almost correct but I've run out of time to make it work.