Ansible role to install and configure Netplan.
Currently supported platforms are:
- Ubuntu 20.04 LTS
- Ubuntu 22.04 LTS
- Ubuntu 24.04 LTS
None.
Sample configuration to set up networking with Netplan:
netplan_ethernets:
- interface_name: 'eth0'
dhcp4: 'no'
routes:
- to: 'default'
via: '10.123.0.1'
addresses:
- '10.123.0.10/24'
nameservers:
addresses:
- '8.8.8.8'
- '9.9.9.9'
search:
- 'domain.local'
- 'domain.name'
Flag decides on whether pre-existing Netplan configuration files should be deleted:
netplan_remove_existing_configs: true
Name of the template providing the Netplan configuration file:
netplan_configuration_file_template: 'config.yaml.j2'
Directory of the Netplan configuration files:
netplan_configuration_dir: '/etc/netplan'
Name of the Netplan configuration file:
netplan_configuration_file: 'config.yaml'
Path to the Netplan configuration file:
netplan_configuration_file_path: "{{ (netplan_configuration_dir, netplan_configuration_file) | path_join }}"
List of packages that need to be installed:
netplan_packages:
- 'netplan.io'
Network configuration file that is present if networking is managed by package ifupdown:
ifupdown_ifstate_file: '/run/network/ifstate'
Before the package ifupdown
can be safely removed netplan networking
needs to be properly configured.
If the package is removed too early, the role will hang.
For that reason this role does not handle the removal of the ifupdown
package.
Please note that networking configurations can not be bootstrapped during role execution. The respective managed nodes need networking to be configured beforehand.
Be aware that this role does not support changing the IP addresses
over which Ansible connects out of the box.
If you change the IP address over which Ansible connects,
you might end up in a hanging role as soon as netplan apply
is executed.
Ansible loses its SSH connection in that case.
None.
- hosts: servers
vars:
netplan_ethernets:
- interface_name: 'eth0'
dhcp4: 'no'
routes:
- to: 'default'
via: '10.123.0.1'
addresses:
- '10.123.0.10/24'
nameservers:
addresses:
- '8.8.8.8'
- '9.9.9.9'
search:
- 'domain.local'
- 'domain.name'
roles:
- role: hifis.toolkit.netplan
This role was created by HIFIS Software Services.