2020-06-06 08:18:25 +00:00
|
|
|
assert node.has_bundle('systemd')
|
|
|
|
|
|
|
|
files = {
|
2020-11-09 13:48:19 +00:00
|
|
|
'/etc/network/interfaces': {
|
|
|
|
'delete': True,
|
|
|
|
},
|
2020-06-06 08:18:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-09 13:48:19 +00:00
|
|
|
directories = {
|
|
|
|
'/etc/systemd/network': {
|
|
|
|
'purge': True,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# Don't use .get() here. We might end up with a node without a network
|
|
|
|
# config!
|
|
|
|
for interface, config in node.metadata['interfaces'].items():
|
2020-11-09 13:58:09 +00:00
|
|
|
if config.get('dhcp', False):
|
|
|
|
template = 'template-dhcp.network'
|
|
|
|
else:
|
|
|
|
template = 'template.network'
|
|
|
|
|
2020-06-06 08:18:25 +00:00
|
|
|
files['/etc/systemd/network/10-{}.network'.format(interface)] = {
|
2020-11-09 13:58:09 +00:00
|
|
|
'source': template,
|
2020-06-06 08:18:25 +00:00
|
|
|
'content_type': 'mako',
|
|
|
|
'context': {
|
|
|
|
'interface': interface,
|
|
|
|
'config': config,
|
|
|
|
},
|
2020-11-09 13:48:19 +00:00
|
|
|
'needed_by': {
|
|
|
|
'svc_systemd:systemd-networkd',
|
|
|
|
},
|
2020-06-06 08:18:25 +00:00
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:systemd-networkd:restart',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
svc_systemd = {
|
|
|
|
'systemd-networkd': {},
|
|
|
|
}
|