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-iface-dhcp.network' else: template = 'template-iface-nodhcp.network' files['/etc/systemd/network/50-iface-{}.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', }, } for bond, config in node.metadata.get('systemd-networkd', {}).get('bonds', {}).items(): files['/etc/systemd/network/20-bond-{}.netdev'.format(bond)] = { 'source': 'template-bond.netdev', 'content_type': 'mako', 'context': { 'bond': bond, 'mode': config.get('mode', '802.3ad'), }, 'needed_by': { 'svc_systemd:systemd-networkd', }, 'triggers': { 'svc_systemd:systemd-networkd:restart', }, } files['/etc/systemd/network/21-bond-{}.network'.format(bond)] = { 'source': 'template-bond.network', 'content_type': 'mako', 'context': { 'bond': bond, 'match': config['match'], }, 'needed_by': { 'svc_systemd:systemd-networkd', }, 'triggers': { 'svc_systemd:systemd-networkd:restart', }, } for brname, config in node.metadata.get('systemd-networkd', {}).get('bridges', {}).items(): files['/etc/systemd/network/30-bridge-{}.netdev'.format(brname)] = { 'source': 'template-bridge.netdev', 'content_type': 'mako', 'context': { 'bridge': brname, }, 'needed_by': { 'svc_systemd:systemd-networkd', }, 'triggers': { 'svc_systemd:systemd-networkd:restart', }, } files['/etc/systemd/network/31-bridge-{}.network'.format(brname)] = { 'source': 'template-bridge.network', 'content_type': 'mako', 'context': { 'bridge': brname, 'match': config['match'], }, 'needed_by': { 'svc_systemd:systemd-networkd', }, 'triggers': { 'svc_systemd:systemd-networkd:restart', }, } svc_systemd = { 'systemd-networkd': {}, }