1
0
IaC/ansible/roles/systemd_networkd/tasks/main.yaml

44 lines
989 B
YAML
Raw Normal View History

2023-08-10 09:32:17 -04:00
---
- 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 }}"
2023-08-13 00:03:03 -04:00
dest: /etc/systemd/network/{{ item.name }}
2023-08-10 09:32:17 -04:00
owner: root
group: root
mode: '0644'
loop: "{{ systemd_networkd_configs }}"
notify:
- Restart systemd-resolved
- Restart systemd-networkd
2023-08-12 06:19:07 -04:00
- name: Get service facts
ansible.builtin.service_facts:
2023-08-10 09:32:17 -04:00
- name: Disable non-systemd networking services
2023-08-12 06:19:07 -04:00
when: item in ansible_facts.services
2023-08-10 09:32:17 -04:00
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