Compare commits
1 commit
7350b01403
...
22e170b2cc
Author | SHA1 | Date | |
---|---|---|---|
22e170b2cc |
6 changed files with 62 additions and 71 deletions
3
bundles/ifupdown/items.py
Normal file
3
bundles/ifupdown/items.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# svc_systemd = {
|
||||||
|
# 'ifupdown.service': {},
|
||||||
|
# }
|
|
@ -36,61 +36,64 @@ def dhcp(metadata):
|
||||||
'systemd/units',
|
'systemd/units',
|
||||||
)
|
)
|
||||||
def units(metadata):
|
def units(metadata):
|
||||||
units = {}
|
if node.has_bundle('systemd-networkd'):
|
||||||
|
units = {}
|
||||||
|
|
||||||
for network_name, network_conf in metadata.get('network').items():
|
for network_name, network_conf in metadata.get('network').items():
|
||||||
interface_type = network_conf.get('type', None)
|
interface_type = network_conf.get('type', None)
|
||||||
|
|
||||||
# network
|
# network
|
||||||
|
|
||||||
units[f'{network_name}.network'] = {
|
units[f'{network_name}.network'] = {
|
||||||
'Match': {
|
'Match': {
|
||||||
'Name': network_name if interface_type == 'vlan' else network_conf['interface'],
|
'Name': network_name if interface_type == 'vlan' else network_conf['interface'],
|
||||||
},
|
|
||||||
'Network': {
|
|
||||||
'DHCP': network_conf.get('dhcp', 'no'),
|
|
||||||
'IPv6AcceptRA': network_conf.get('dhcp', 'no'),
|
|
||||||
'VLAN': set(network_conf.get('vlans', set()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# type
|
|
||||||
|
|
||||||
if interface_type:
|
|
||||||
units[f'{network_name}.network']['Match']['Type'] = interface_type
|
|
||||||
|
|
||||||
# ips
|
|
||||||
|
|
||||||
for i in [4, 6]:
|
|
||||||
if network_conf.get(f'ipv{i}', None):
|
|
||||||
units[f'{network_name}.network'].update({
|
|
||||||
f'Address#ipv{i}': {
|
|
||||||
'Address': network_conf[f'ipv{i}'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if f'gateway{i}' in network_conf:
|
|
||||||
units[f'{network_name}.network'].update({
|
|
||||||
f'Route#ipv{i}': {
|
|
||||||
'Gateway': network_conf[f'gateway{i}'],
|
|
||||||
'GatewayOnlink': 'yes',
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
# as vlan
|
|
||||||
|
|
||||||
if interface_type == 'vlan':
|
|
||||||
units[f"{network_name}.netdev"] = {
|
|
||||||
'NetDev': {
|
|
||||||
'Name': network_name,
|
|
||||||
'Kind': 'vlan',
|
|
||||||
},
|
},
|
||||||
'VLAN': {
|
'Network': {
|
||||||
'Id': network_conf['id'],
|
'DHCP': network_conf.get('dhcp', 'no'),
|
||||||
|
'IPv6AcceptRA': network_conf.get('dhcp', 'no'),
|
||||||
|
'VLAN': set(network_conf.get('vlans', set()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
# type
|
||||||
'systemd': {
|
|
||||||
'units': units,
|
if interface_type:
|
||||||
|
units[f'{network_name}.network']['Match']['Type'] = interface_type
|
||||||
|
|
||||||
|
# ips
|
||||||
|
|
||||||
|
for i in [4, 6]:
|
||||||
|
if network_conf.get(f'ipv{i}', None):
|
||||||
|
units[f'{network_name}.network'].update({
|
||||||
|
f'Address#ipv{i}': {
|
||||||
|
'Address': network_conf[f'ipv{i}'],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if f'gateway{i}' in network_conf:
|
||||||
|
units[f'{network_name}.network'].update({
|
||||||
|
f'Route#ipv{i}': {
|
||||||
|
'Gateway': network_conf[f'gateway{i}'],
|
||||||
|
'GatewayOnlink': 'yes',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
# as vlan
|
||||||
|
|
||||||
|
if interface_type == 'vlan':
|
||||||
|
units[f"{network_name}.netdev"] = {
|
||||||
|
'NetDev': {
|
||||||
|
'Name': network_name,
|
||||||
|
'Kind': 'vlan',
|
||||||
|
},
|
||||||
|
'VLAN': {
|
||||||
|
'Id': network_conf['id'],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
'systemd': {
|
||||||
|
'units': units,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else:
|
||||||
|
return {}
|
||||||
|
|
|
@ -13,6 +13,7 @@ defaults = {
|
||||||
'os-prober': {
|
'os-prober': {
|
||||||
'installed': False,
|
'installed': False,
|
||||||
},
|
},
|
||||||
|
'dnsmasq-base': {},
|
||||||
},
|
},
|
||||||
'sources': {
|
'sources': {
|
||||||
'proxmox-ve': {
|
'proxmox-ve': {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
assert node.has_bundle('systemd')
|
assert node.has_bundle('systemd')
|
||||||
|
|
||||||
files = {
|
files = {
|
||||||
|
'/etc/network/interfaces': {
|
||||||
|
'delete': True,
|
||||||
|
},
|
||||||
'/etc/resolv.conf': {
|
'/etc/resolv.conf': {
|
||||||
'content_type': 'mako',
|
'content_type': 'mako',
|
||||||
},
|
},
|
||||||
|
@ -18,9 +21,3 @@ directories = {
|
||||||
svc_systemd = {
|
svc_systemd = {
|
||||||
'systemd-networkd.service': {},
|
'systemd-networkd.service': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if not node.has_bundle('proxmox-ve'):
|
|
||||||
files['/etc/network/interfaces'] = {
|
|
||||||
'delete': True,
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'ifupdown',
|
'ifupdown',
|
||||||
|
'proxmox-ve',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
'groups': [
|
'groups': [
|
||||||
'autologin',
|
'autologin',
|
||||||
'backup',
|
'backup',
|
||||||
'debian-12',
|
'debian-12-pve',
|
||||||
'home',
|
'home',
|
||||||
'nextcloud',
|
'nextcloud',
|
||||||
'monitored',
|
'monitored',
|
||||||
|
@ -32,10 +32,8 @@
|
||||||
'systemd-swap',
|
'systemd-swap',
|
||||||
'twitch-clip-download',
|
'twitch-clip-download',
|
||||||
'raspberrymatic-cert',
|
'raspberrymatic-cert',
|
||||||
#'tasmota-charge',
|
|
||||||
'wol-waker',
|
'wol-waker',
|
||||||
'zfs',
|
'zfs',
|
||||||
'proxmox-ve',
|
|
||||||
],
|
],
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'id': 'af96709e-b13f-4965-a588-ef2cd476437a',
|
'id': 'af96709e-b13f-4965-a588-ef2cd476437a',
|
||||||
|
@ -156,18 +154,6 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'systemd-swap': 4_000_000_000,
|
'systemd-swap': 4_000_000_000,
|
||||||
'tasmota-charge': {
|
|
||||||
'phone': {
|
|
||||||
'ip': '10.0.0.175',
|
|
||||||
'user': 'u0_a233',
|
|
||||||
'password': 'november',
|
|
||||||
},
|
|
||||||
'plug': {
|
|
||||||
'ip': '10.0.2.115',
|
|
||||||
'min': 45,
|
|
||||||
'max': 70,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'twitch-clip-download': {
|
'twitch-clip-download': {
|
||||||
'channel_name': 'cronekorkn_',
|
'channel_name': 'cronekorkn_',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue