bundlewrap/bundles/systemd-networkd/items.py

41 lines
904 B
Python
Raw Normal View History

2020-06-06 08:18:25 +00:00
assert node.has_bundle('systemd')
files = {
'/etc/network/interfaces': {
'delete': True,
},
2020-06-06 08:18:25 +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():
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)] = {
'source': template,
2020-06-06 08:18:25 +00:00
'content_type': 'mako',
'context': {
'interface': interface,
'config': config,
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
2020-06-06 08:18:25 +00:00
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
svc_systemd = {
'systemd-networkd': {},
}