Mercurial > code > home > repos > infra
comparison net.py @ 278:4e424a144183
for netboot pi
author | drewp@bigasterisk.com |
---|---|
date | Sat, 30 Mar 2024 00:15:46 -0700 |
parents | 058c312ffdce |
children | 0befc8696a07 |
comparison
equal
deleted
inserted
replaced
277:ce823a167641 | 278:4e424a144183 |
---|---|
1 from pyinfra import host | 1 from pyinfra import host |
2 from pyinfra.operations import apt, files, server, systemd | 2 from pyinfra.operations import apt, files, server, systemd |
3 from pyinfra.facts.server import Arch, LinuxDistribution | |
3 | 4 |
4 is_wifi = host.name in ['living', 'plus'] | 5 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] |
5 | 6 is_wifi = False |
6 | 7 |
7 def cleanup(): | 8 def cleanup(): |
8 # past attempts | 9 # past attempts |
9 files.file(path='/etc/network/interfaces', present=False) | 10 files.file(path='/etc/network/interfaces', present=False) |
10 | 11 |
37 'update-alternatives --set iptables /usr/sbin/iptables-legacy', | 38 'update-alternatives --set iptables /usr/sbin/iptables-legacy', |
38 'update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy', | 39 'update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy', |
39 ]) | 40 ]) |
40 # needs reboot if this changed | 41 # needs reboot if this changed |
41 | 42 |
42 if host.name in ['slash', 'dash', 'dot', 'squib', 'pillow']: | 43 if host.name in ['prime', 'bang', 'pipe', 'ditto']: |
43 pass # don't break k3s networking! the else-part really breaks it | |
44 else: | |
45 server.sysctl(key='net.ipv6.conf.all.disable_ipv6', value=1, persist=True) | 44 server.sysctl(key='net.ipv6.conf.all.disable_ipv6', value=1, persist=True) |
46 | 45 |
47 # if is_wifi_pi: | 46 # if is_wifi_pi: |
48 # files.put(dest="/etc/network/interfaces.d/wlan0", src="files/pi_wlan0_powersave") | 47 # files.put(dest="/etc/network/interfaces.d/wlan0", src="files/pi_wlan0_powersave") |
49 # ssh.command(host.name, "iw wlan0 set power_save off") | 48 # ssh.command(host.name, "iw wlan0 set power_save off") |
98 ) | 97 ) |
99 apt.packages(packages=['network-manager'], present=False) | 98 apt.packages(packages=['network-manager'], present=False) |
100 | 99 |
101 systemd.service(service='systemd-networkd.service', enabled=True, running=True, restarted=True) | 100 systemd.service(service='systemd-networkd.service', enabled=True, running=True, restarted=True) |
102 | 101 |
103 # TODO this breaks wg on garage, i think. workaround: | 102 # delete? |
104 if host.name == 'garage': | 103 # # TODO this breaks wg on garage, i think. workaround: |
105 server.shell('ip -4 address add 10.5.0.14/24 dev wg0') | 104 # if host.name == 'garage': |
105 # server.shell('ip -4 address add 10.5.0.14/24 dev wg0') | |
106 else: | |
107 pass # don't break working networking! |