bundlewrap/bundles/systemd-networkd/items.py

49 lines
1 KiB
Python

assert node.has_bundle('systemd')
pkg_apt = {
'resolvconf': {
'installed': False,
},
}
files = {
'/etc/network/interfaces': {
'delete': True,
},
'/etc/resolv.conf': {
'content_type': 'mako',
},
}
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': {},
}