-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsystemd-netdev.sls
82 lines (70 loc) · 1.98 KB
/
systemd-netdev.sls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{%- set netifaces = pillar['network']['interfaces'] %}
rm -f /etc/systemd/network/[a-z]*.netdev:
cmd.run:
- onlyif:
- ls /etc/systemd/network/[a-z]*.netdev
{%- for iface in netifaces recursive %}
{%- set filename = '20-'+iface.name+'.netdev' %}
{%- set filepath = '/etc/systemd/network/'+filename %}
## BOND begin
{%- if iface.type == 'bond' %}
# Bug https://github.com/saltstack/salt/issues/34236 workaround begin
ensure {{ filename }} exists with ini sections:
cmd.run:
- name: echo '[NetDev]' > {{ filepath }}
- unless:
- test -f {{ filepath }}
- require_in:
- ini: {{ filepath }}
- require:
- file: /etc/systemd/network
# Bug workaround end
{{ filepath }}:
ini.options_present:
- sections:
NetDev:
Name: "{{ iface.name }}"
Kind: "bond"
{%- if iface.mtu is defined %}
MTUBytes: "{{ iface.mtu }}"
{%- endif %}
Bond:
Mode: "{{ iface.mode }}"
{%- if iface.xmit_hash_policy is defined %}
TransmitHashPolicy: "{{ iface.xmit_hash_policy }}"
{%- endif %}
{%- if iface.miimon is defined %}
MIIMonitorSec: "{{ iface.miimon }}"
{%- else %}
MIIMonitorSec: "1s"
{%- endif %}
- watch_in:
- module: restart_systemd-networkd
{%- endif %}
## BOND END
## VLAN begin
{% if iface.type == 'vlan' %}
ensure {{ filename }} exists with ini sections:
# Bug https://github.com/saltstack/salt/issues/34236 workaround begin
cmd.run:
- name: echo '[NetDev]' > {{ filepath }}
- unless:
- test -f {{ filepath }}
- require_in:
- ini: {{ filepath }}
- require:
- file: /etc/systemd/network
# Bug workaround end
{{ filepath }}:
ini.options_present:
- sections:
NetDev:
Name: "{{ iface.name }}"
Kind: "vlan"
VLAN:
Id: "{{ iface.tag }}"
- watch_in:
- module: restart_systemd-networkd
{%- endif %}
## VLAN END
{%- endfor %}