40 lines
904 B
Python
40 lines
904 B
Python
assert node.has_bundle('systemd')
|
|
|
|
files = {
|
|
'/etc/network/interfaces': {
|
|
'delete': True,
|
|
},
|
|
}
|
|
|
|
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():
|
|
if config.get('dhcp', False):
|
|
template = 'template-dhcp.network'
|
|
else:
|
|
template = 'template.network'
|
|
|
|
files['/etc/systemd/network/10-{}.network'.format(interface)] = {
|
|
'source': template,
|
|
'content_type': 'mako',
|
|
'context': {
|
|
'interface': interface,
|
|
'config': config,
|
|
},
|
|
'needed_by': {
|
|
'svc_systemd:systemd-networkd',
|
|
},
|
|
'triggers': {
|
|
'svc_systemd:systemd-networkd:restart',
|
|
},
|
|
}
|
|
|
|
svc_systemd = {
|
|
'systemd-networkd': {},
|
|
}
|