Getting started

Replacing ifupdown scripts with systemd-networkd

The default non-GUI Debian installation uses the ifupdown package to configure network interfaces. It's not compatible with the systemd-networkd service, therefore it's best to purge it from the host after the new configuration has been applied. This has to be done through local console, since during removal the post-rm scripts will bring the network interfaces down, disconnecting the host from the network.

Specific steps to take to replace the ifupdown package with systemd-networkd service:

  1. Make sure that the host is in the [debops_service_networkd] Ansible inventory group.

    [debops_all_hosts]
    hostname
    
    [debops_service_networkd]
    hostname
    
  2. Apply the debops.networkd playbook, check if the host has network connection.

    user@host:~$ debops check service/networkd -l hostname
    user@host:~$ debops run service/networkd -l hostname
    
  3. Login to the host on the local console, purge ifupdown package and reboot the host.

    user@host:~$ sudo apt purge ifupdown
    user@host:~$ sudo systemctl reboot
    
  4. Login to the host and check if the new configuration has been set up correctly. Apply the debops.resolved playbook to configure /etc/resolv.conf configuration file.

    user@host:~$ debops check service/resolved -l hostname
    user@host:~$ debops run service/resolved -l hostname
    

Example inventory

To manage the network configuration using systemd-networkd service, the host needs to be included in the [debops_service_networkd] Ansible inventory group:

[debops_all_hosts]
hostname

[debops_service_networkd]
hostname

Example playbook

If you are using this role without DebOps, here's an example Ansible playbook that uses the debops.networkd role:

---

- name: Manage systemd-networkd service
  collections: [ 'debops.debops', 'debops.roles01',
                 'debops.roles02', 'debops.roles03' ]
  hosts: [ 'debops_service_networkd' ]
  become: True

  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'

  roles:

    - role: networkd
      tags: [ 'role::networkd', 'skip::networkd' ]

Ansible tags

You can use Ansible --tags or --skip-tags parameters to limit what tasks are performed during Ansible run. This can be used after a host was first configured to speed up playbook execution, when you are sure that most of the configuration is already in the desired state.

Available role tags:

role::networkd

Main role tag, should be used in the playbook to execute all of the role tasks as well as role dependencies.