comparison system.py @ 10:1fec9fe18a4e

more system.py cleanup; add pi /boot/config.txt
author drewp@bigasterisk.com
date Thu, 11 Nov 2021 22:22:34 -0800
parents aa633eb49c63
children 15c5ce7c74b5
comparison
equal deleted inserted replaced
9:7e76e6dcc080 10:1fec9fe18a4e
1 import os 1 import os
2
2 from pyinfra import host 3 from pyinfra import host
3 from pyinfra.operations import server, files, apt, ssh, systemd
4 from pyinfra.facts.server import LinuxDistribution 4 from pyinfra.facts.server import LinuxDistribution
5 from pyinfra.operations import apt, files, server, ssh, systemd
5 6
6 bang_is_old = True # remove after upgrade 7 bang_is_old = True # remove after upgrade
7 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] 8 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux']
8 is_wifi_pi = host.name in ['frontdoor', 'living'] 9 is_wifi_pi = host.name in ['frontdoor', 'living']
9 10
64 65
65 if is_wifi_pi: 66 if is_wifi_pi:
66 files.put(dest="/etc/network/interfaces.d/wlan0", src="files/pi_wlan0_powersave") 67 files.put(dest="/etc/network/interfaces.d/wlan0", src="files/pi_wlan0_powersave")
67 ssh.command(host.name, "iw wlan0 set power_save off") 68 ssh.command(host.name, "iw wlan0 set power_save off")
68 69
69 # see https://www.raspberrypi.org/documentation/configuration/config-txt/memory.md#:~:text=txt-,gpu_mem,-Specifies 70 files.template(src='templates/boot_config.txt.j2', dest='/boot/config.txt')
70 # to port to pyinfra
71 #- name: unused display; give ram to OS
72 # lineinfile: dest=/boot/config.txt line="gpu_mem=16" regexp="^gpu_mem="
73 # when: "'with_x11' not in group_names"
74 71
75 # for beacon 72 if not is_pi and host.name != 'prime':
76 #enable_uart=1
77 #dtoverlay=pi3-miniuart-bt
78 #core_freq=250
79
80 # for tiny_screen
81 #to port to pyinfra
82 #- lineinfile: dest=/boot/config.txt line="dtparam=spi=on" regexp="^dtparam=spi="
83
84 # i hope this is deletable
85 # downgrade strictness so I can install from https://archive.raspberrypi.org/
86 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=907788
87 #- lineinfile: dest=/etc/ssl/openssl.cnf line="#CipherString = DEFAULT@SECLEVEL=2" regexp="CipherString ?="
88
89 # may be fixed in k3s, not sure
90 # raspbian defaults to `iptables -V` -> iptables v1.8.4 (nf_tables), which won't work with k3s
91 # - command: update-alternatives --set iptables /usr/sbin/iptables-legacy
92 if not is_pi:
93 apt.key(src='https://dl.google.com/linux/linux_signing_key.pub') 73 apt.key(src='https://dl.google.com/linux/linux_signing_key.pub')
94 apt.repo(src='deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main') 74 apt.repo(src='deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main')
95 75
96 apt.key(src='https://packages.microsoft.com/keys/microsoft.asc') 76 apt.key(src='https://packages.microsoft.com/keys/microsoft.asc')
97 apt.repo(src="deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code stable main") 77 apt.repo(src="deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code stable main")
99 apt.ppa(src="ppa:savoury1/blender") 79 apt.ppa(src="ppa:savoury1/blender")
100 80
101 apt.key(keyserver='keyserver.ubuntu.com', keyid='F24AEA9FB05498B7') 81 apt.key(keyserver='keyserver.ubuntu.com', keyid='F24AEA9FB05498B7')
102 apt.repo(src="deb [arch=amd64,i386] https://repo.steampowered.com/steam/ stable steam") 82 apt.repo(src="deb [arch=amd64,i386] https://repo.steampowered.com/steam/ stable steam")
103 83
104 if False and is_pi:
105 apt.key(src="https://download.docker.com/linux/raspbian/gpg")
106 apt.repo(src="deb [arch=armhf] https://download.docker.com/linux/raspbian stretch stable")
107 apt.repo(src='deb http://deb.debian.org/debian/ unstable main') # maybe for WG
108
109 apt.packages(packages=[ 84 apt.packages(packages=[
110 'build-essential', 85 'build-essential',
111 # 'i2c-tools', 86 # 'i2c-tools',
112 'rsync', 87 'rsync',
88 'dstat',
89 'ifstat',
113 ]) 90 ])
114 91
115 if not is_pi: 92 if not is_pi:
116 apt.packages(packages=[ 93 apt.packages(packages=[
117 'keychain', 94 'keychain',
172 'libzfs2linux', 149 'libzfs2linux',
173 'zfsutils-linux', 150 'zfsutils-linux',
174 'zfs-zed', 151 'zfs-zed',
175 'zfs-auto-snapshot', 152 'zfs-auto-snapshot',
176 ]) 153 ])
177
178 # This is usable on pi where we don't care when they reboot:
179 #- name: apt_upgrade
180 # apt: upgrade=full
181 #- name: Check if a reboot is required
182 # register: file
183 # stat: path=/var/run/reboot-required get_md5=no
184 #- name: Reboot the server
185 # command: /sbin/reboot
186 # when: file.stat.exists == true