Real inital commit
This commit is contained in:
34
tasks/deploy_configs.yml
Normal file
34
tasks/deploy_configs.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
|
||||
- name: networkd | Deploy .link configs
|
||||
template:
|
||||
src: networkd.j2
|
||||
dest: "/etc/systemd/network/{{ item.priority }}-{{ item.name }}.link"
|
||||
mode: 644
|
||||
owner: root
|
||||
group: root
|
||||
with_items: "{{ networkd.link | default([]) }}"
|
||||
register: networkd_deployed_link
|
||||
notify: networkd | Reload configuration
|
||||
|
||||
- name: networkd | Deploy .netdev configs
|
||||
template:
|
||||
src: networkd.j2
|
||||
dest: "/etc/systemd/network/{{ item.priority }}-{{ item.name }}.netdev"
|
||||
mode: 644
|
||||
owner: root
|
||||
group: root
|
||||
with_items: "{{ networkd.netdev | default([]) }}"
|
||||
register: networkd_deployed_netdev
|
||||
notify: networkd | Reload configuration
|
||||
|
||||
- name: networkd | Deploy .network configs
|
||||
template:
|
||||
src: networkd.j2
|
||||
dest: "/etc/systemd/network/{{ item.priority }}-{{ item.name }}.network"
|
||||
mode: 644
|
||||
owner: root
|
||||
group: root
|
||||
with_items: "{{ networkd.network | default([]) }}"
|
||||
register: networkd_deployed_network
|
||||
notify: networkd | Reload configuration
|
22
tasks/main.yml
Normal file
22
tasks/main.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
|
||||
- import_tasks: deploy_configs.yml
|
||||
|
||||
- import_tasks: remove_unmanaged.yml
|
||||
|
||||
- name: networkd | Deploy resolv.conf
|
||||
template:
|
||||
src: resolv.conf.j2
|
||||
dest: /etc/resolv.conf
|
||||
mode: 644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: networkd | Enable and start service
|
||||
systemd:
|
||||
name: systemd-networkd
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: networkd | Run handlers now
|
||||
meta: flush_handlers
|
20
tasks/remove_unmanaged.yml
Normal file
20
tasks/remove_unmanaged.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: networkd | Collect file list in network dir
|
||||
find:
|
||||
path: /etc/systemd/network
|
||||
hidden: yes
|
||||
register: networkd_found_files
|
||||
check_mode: no
|
||||
changed_when: false
|
||||
|
||||
- name: networkd | Remove unmanaged files
|
||||
file:
|
||||
path: "/etc/systemd/network/{{ item.path | basename }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ networkd_found_files.files }}"
|
||||
when:
|
||||
- (item.path) not in ( networkd_deployed_link | json_query('results[].invocation.module_args.dest') | default([]) )
|
||||
- (item.path) not in ( networkd_deployed_netdev | json_query('results[].invocation.module_args.dest') | default([]) )
|
||||
- (item.path) not in ( networkd_deployed_network | json_query('results[].invocation.module_args.dest') | default([]) )
|
||||
notify: networkd | Reload configuration
|
Reference in New Issue
Block a user