r/systemd-networkd: Role to configure networkd

*systemd-networkd* is (currently) my preferred way to manage network
interfaces on machines running Fedora.  The *systemd-networkd* role
provides a generic way to configure network links, devices, and
interfaces, using Ansible variables to generate network unit
configuration files.
jenkins-master
Dustin 2021-10-10 11:54:12 -05:00
parent 11357a9df3
commit 2708dfe3f2
6 changed files with 59 additions and 0 deletions

View File

@ -20,6 +20,8 @@ koji0.pyrocufflink.blue
[koji-web]
koji0.pyrocufflink.blue
[networkd]
[pyrocufflink]
koji0.pyrocufflink.blue
taiga0.pyrocufflink.blue

View File

@ -0,0 +1,3 @@
networkd_links: []
networkd_devices: []
networkd_networks: []

View File

@ -0,0 +1,2 @@
- name: reload networkd
command: networkctl reload

View File

@ -0,0 +1,34 @@
- name: ensure systemd-networkd is installed
package:
name: systemd-networkd
state: present
tags:
- install
- name: ensure systemd network configuration directory exists
file:
path: /etc/systemd/network
mode: '0755'
state: directory
- name: ensure systemd network links are configured
template:
src: network.j2
dest: /etc/systemd/network/{{ item.name }}.link
mode: '0644'
loop: '{{ networkd_links }}'
notify: reload networkd
- name: ensure systemd network devices are configured
template:
src: network.j2
dest: /etc/systemd/network/{{ item.name }}.netdev
mode: '0644'
loop: '{{ networkd_devices }}'
notify: reload networkd
- name: ensure systemd networks are configured
template:
src: network.j2
dest: /etc/systemd/network/{{ item.name }}.network
mode: '0644'
loop: '{{ networkd_networks }}'
notify: reload networkd

View File

@ -0,0 +1,12 @@
{% for section in item if section != "name" %}
[{{ section }}]
{% for key in item[section] %}
{% if item[section][key] is not iterable or item[section][key] is string %}
{{ key }}={{ item[section][key] }}
{% else %}
{% for value in item[section][key] %}
{{ key }}={{ value }}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}

6
systemd-networkd.yml Normal file
View File

@ -0,0 +1,6 @@
- hosts: networkd
roles:
- role: systemd-networkd
tags:
- networkd
- netconfig