Skip to content

Ansible Role linuxfabrik.lfops.network

This role is a thin wrapper around the fedora.linux_system_roles.network role, the upstream Linux System Role for declaring network connections (ethernet, bonds, bridges, VLANs, IP / DNS / route configuration, ...) on top of NetworkManager. It additionally cleans up Hetzner-specific cruft that conflicts with NetworkManager.

Concretely, this role:

  • Calls fedora.linux_system_roles.network with whatever network_connections or network_state you pass in (host or group vars). With neither set, the upstream role is not called at all, so it neither installs nor starts NetworkManager.
  • If network_state is set, first clears DNS servers from the connection profile that is active on each declared interface (for example cloud-init eth0 or System eth0), because nmstate carries the DNS servers stored in that profile over into the profile it writes (nmstate#3251):

    • A stored ipv6.dns goes if network_state disables IPv6 or leaves it at link-local, with or without dns-resolver. Otherwise the apply aborts with ipv6.dns: this property is not allowed for 'method=disabled'.
    • With dns-resolver declared, the stored servers it does not list go as well; they would otherwise stay behind on interfaces that do not hold the configured ones.

    The profile is only edited, not deleted or re-applied, so the active connection stays up, and a profile without such servers is left alone. * On Red Hat-family hosts only: removes the hc-utils package (Hetzner Cloud utilities). They install legacy ifcfg scripts that fight with NetworkManager. The task tolerates the package not being installed (ignore_errors: true). * Prints a reminder that NetworkManager may need to be restarted by hand (systemctl restart NetworkManager) whenever the upstream role changed a connection profile. The upstream role applies connections via NetworkManager APIs, but a few changes (e.g. plugin reloads) require a service restart. The reminder is repeated in the block of manual steps that every LFOps playbook prints above the PLAY RECAP.

Available since LFOps 2.0.0.

Known Limitations

  • Teaming (type: 'team') is not available on RHEL 10 and later. The upstream role aborts the run with a message pointing at bonding, so a host that carried a team connection on RHEL 9 has to be converted to type: 'bond' before it is upgraded.

Requirements

Manual steps:

  • Install the Linux System Roles on the Ansible control node, e.g. via ansible-galaxy collection install fedora.linux_system_roles.

Tags

network

  • Configures the network, clears stale DNS servers from the active connection profiles of network_state interfaces, and removes hc-utils (Hetzner) on Red Hat hosts.
  • Triggers: none.

Optional Role Variables

This role does not define its own variables. All configuration is passed straight through to fedora.linux_system_roles.network. See the upstream README for the full list (network_connections, network_provider, network_state, ...).

Example:

network_connections:

  - name: 'eth0'
    type: 'ethernet'
    autoconnect: true
    ip:
      address:
        - '192.0.2.26/32'
      dhcp4: false
      ipv6_disabled: true
      gateway4: '192.0.2.1'
      auto_gateway: true
      dns:
        - '1.1.1.1'
      dns_search:
        - 'example.com'
    state: 'up'

  # remove the default connections
  # check with `nmcli connection show`
  - name: 'cloud-init eth0'
    persistent_state: 'absent'
  - name: 'System eth0'
    persistent_state: 'absent'
  - name: 'System eth1'
    persistent_state: 'absent'

License

The Unlicense

Author Information

Linuxfabrik GmbH, Zurich