xoxys.network/tasks/nm.yml

30 lines
921 B
YAML
Raw Normal View History

---
2024-02-18 12:02:37 +00:00
- name: Add NetworkManager configuration
ansible.builtin.copy:
content: "{{ item.value }}"
dest: "/etc/NetworkManager/conf.d/{{ item.key }}.conf"
owner: root
group: root
mode: "0640"
loop: "{{ network_nm_config | dict2items }}"
loop_control:
label: "{{ item.key }}"
notify: __network_host_reboot
2024-02-18 12:02:37 +00:00
- name: Register active NetworkManager configuration
ansible.builtin.find:
paths: /etc/NetworkManager/conf.d/
file_type: file
patterns: "*.conf"
register: __network_nm_config_active
changed_when: False
failed_when: False
2024-02-18 12:02:37 +00:00
- name: Remove unmanaged NetworkManager configuration
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop: "{{ __network_nm_config_active.files | map(attribute='path') | list }}"
notify: __network_host_reboot
when: (item | basename | splitext | first) not in (network_nm_config | dict2items | map(attribute='key') | list)