ansible/roles/network/tasks/systemd-networkd.yml

34 lines
1.1 KiB
YAML

---
# systemd-networkd
- name: manage systemd-networkd package
package:
name: "{{ _network_systemd_networkd_package_name }}"
state: "{{ _network_systemd_networkd_enabled | ternary('present', 'absent') }}"
when: _systemd_networkd_package_name is defined
- name: manage systemd-networkd service
service:
name: "{{ _network_systemd_networkd_service_name }}"
state: "{{ _network_systemd_networkd_enabled | ternary('started', 'stopped') }}"
enabled: "{{ _network_systemd_networkd_enabled }}"
- name: configure systemd-networkd
template:
src: systemd-network.j2
dest: "/etc/systemd/network/05-{{ item.name }}.network"
notify: restart systemd-networkd
with_items: "{{ network_interfaces }}"
when:
- network_interfaces is defined
- _network_systemd_networkd_enabled | bool
- name: configure systemd-networkd default interface
template:
src: systemd-network.j2
dest: "/etc/systemd/network/05-{{ ansible_default_ipv4.interface }}.network"
notify: restart systemd-networkd
when:
- network_interfaces is not defined
- _network_systemd_networkd_enabled | bool