WIP: Infrastructure routers #91
4 changed files with 74 additions and 0 deletions
20
roles/systemd_networkd/handlers/main.yml
Normal file
20
roles/systemd_networkd/handlers/main.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
- name: Update initramfs
|
||||
command:
|
||||
cmd: update-initramfs -u
|
||||
|
||||
- name: Restart systemd-networkd
|
||||
systemd:
|
||||
name: systemd-networkd.service
|
||||
state: restarted
|
||||
|
||||
- name: Reboot required
|
||||
file:
|
||||
path: /var/run/reboot-required
|
||||
state: touch
|
||||
modification_time: preserve
|
||||
access_time: preserve
|
||||
owner: root
|
||||
group: root
|
||||
mode: u=rw,g=r,o=r
|
||||
...
|
30
roles/systemd_networkd/tasks/main.yml
Normal file
30
roles/systemd_networkd/tasks/main.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
- name: Configure interfaces links
|
||||
template:
|
||||
src: link.j2
|
||||
dest: "/etc/systemd/network/10-{{ item.key }}.link"
|
||||
owner: root
|
||||
group: systemd-network
|
||||
mode: u=rw,g=r,o=
|
||||
loop: "{{ networkd_interfaces | dict2items }}"
|
||||
notify:
|
||||
- Update initramfs
|
||||
- Reboot required
|
||||
|
||||
- name: Configure interfaces networks
|
||||
template:
|
||||
src: network.j2
|
||||
dest: "/etc/systemd/network/10-{{ item.key }}.network"
|
||||
owner: root
|
||||
group: systemd-network
|
||||
mode: u=rw,g=r,o=
|
||||
loop: "{{ networkd_interfaces | dict2items }}"
|
||||
notify:
|
||||
- Restart systemd-networkd
|
||||
|
||||
- name: Enable and start systemd-networkd
|
||||
systemd:
|
||||
name: systemd-networkd.service
|
||||
enabled: true
|
||||
state: started
|
||||
...
|
7
roles/systemd_networkd/templates/link.j2
Normal file
7
roles/systemd_networkd/templates/link.j2
Normal file
|
@ -0,0 +1,7 @@
|
|||
{{ ansible_managed | comment }}
|
||||
|
||||
[Match]
|
||||
MACAddress={{ item.value.mac_addr }}
|
||||
|
||||
[Link]
|
||||
Name={{ item.key }}
|
17
roles/systemd_networkd/templates/network.j2
Normal file
17
roles/systemd_networkd/templates/network.j2
Normal file
|
@ -0,0 +1,17 @@
|
|||
{{ ansible_managed | comment }}
|
||||
|
||||
[Match]
|
||||
Name={{ item.key }}
|
||||
|
||||
{% if not (item.value.link_local | default(true)) %}
|
||||
[Network]
|
||||
LinkLocalAddressing=no
|
||||
{% endif %}
|
||||
|
||||
{% for addr in item.value.ip_addrs | default([]) %}
|
||||
[Address]
|
||||
Address={{ addr }}
|
||||
{% endfor %}
|
||||
|
||||
[FairQueueingControlledDelay]
|
||||
Parent=root
|
Loading…
Reference in a new issue