1
0
IaC/ansible/roles/systemd_networkd/tasks/main.yaml
2023-08-13 14:03:03 +10:00

44 lines
989 B
YAML

---
- name: Clear systemd-networkd config directory
ansible.builtin.file:
path: "/etc/systemd/network/"
state: "{{ item }}"
owner: root
group: root
mode: '0755'
with_items:
- absent
- directory
- name: Create systemd-networkd config files
ansible.builtin.template:
src: "{{ item.src }}"
dest: /etc/systemd/network/{{ item.name }}
owner: root
group: root
mode: '0644'
loop: "{{ systemd_networkd_configs }}"
notify:
- Restart systemd-resolved
- Restart systemd-networkd
- name: Get service facts
ansible.builtin.service_facts:
- name: Disable non-systemd networking services
when: item in ansible_facts.services
ansible.builtin.service:
name: "{{ item }}"
state: stopped
enabled: false
loop: "{{ default_network_services[ansible_os_family] }}"
- name: Enable systemd networking
ansible.builtin.service:
name: "{{ item }}"
enabled: true
loop:
- systemd-networkd
- systemd-resolved