annotate packages.py @ 283:0befc8696a07

ws
author drewp@bigasterisk.com
date Mon, 15 Apr 2024 02:28:05 -0700
parents ce823a167641
children 73ec5064da44
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
271
drewp@bigasterisk.com
parents: 268
diff changeset
1 from io import StringIO
12
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
2 from pyinfra import host
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
3 from pyinfra.facts.server import LinuxDistribution
186
db4b3a07a3dc run pigpiod
drewp@bigasterisk.com
parents: 174
diff changeset
4 from pyinfra.operations import apt, files, server, systemd
205
826db3c40fa7 whitespace/etc
drewp@bigasterisk.com
parents: 203
diff changeset
5
114
7e280bf26dba package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents: 108
diff changeset
6 import package_lists
12
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
7
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
8 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux']
103
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
9
12
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
10
103
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
11 def kitty():
246
cb9dce5b0731 update kitty
drewp@bigasterisk.com
parents: 240
diff changeset
12 vers = '0.31.0' # see https://github.com/kovidgoyal/kitty/releases
103
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
13 home = '/home/drewp'
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
14 local = f"{home}/.local/kitty"
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
15 dl = f'/tmp/kitty-{vers}-x86_64.txz'
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
16 files.download(src=f"https://github.com/kovidgoyal/kitty/releases/download/v{vers}/kitty-{vers}-x86_64.txz", dest=dl)
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
17 files.directory(local)
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
18 server.shell([
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
19 f"mkdir -p {local}", # https://github.com/Fizzadar/pyinfra/issues/777
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
20 f"aunpack --extract-to={local} {dl}",
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
21 ])
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
22 files.link(target="{local}/bin/kitty", path="{home}/bin/kitty")
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
23
12
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
24
174
b6b11048d0fb collect nodejs pkg install stuff together
drewp@bigasterisk.com
parents: 169
diff changeset
25 def nodejs():
b6b11048d0fb collect nodejs pkg install stuff together
drewp@bigasterisk.com
parents: 169
diff changeset
26 apt.packages(packages=['libnode72'], present=False, force=True)
b6b11048d0fb collect nodejs pkg install stuff together
drewp@bigasterisk.com
parents: 169
diff changeset
27 apt.packages(packages=['nodejs'], latest=True)
103
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
28 server.shell([
169
5a8c25d62578 pnpm upgrade
drewp@bigasterisk.com
parents: 150
diff changeset
29 "rm -f /usr/local/bin/pnp{m,x}",
5a8c25d62578 pnpm upgrade
drewp@bigasterisk.com
parents: 150
diff changeset
30 "corepack enable",
103
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
31 # https://github.com/pnpm/pnpm/releases
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
32 # but also https://pnpm.io/installation#compatibility
203
3fd439ae1380 minor & some upgrades
drewp@bigasterisk.com
parents: 196
diff changeset
33 "corepack prepare 'pnpm@8.6.3' --activate",
103
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
34 ])
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
35
283
drewp@bigasterisk.com
parents: 277
diff changeset
36
273
f7178138b736 pkgs and special podman future version
drewp@bigasterisk.com
parents: 271
diff changeset
37 def podman():
f7178138b736 pkgs and special podman future version
drewp@bigasterisk.com
parents: 271
diff changeset
38 apt.packages(packages=['libsubid4', 'buildah', 'podman-docker'], latest=True)
f7178138b736 pkgs and special podman future version
drewp@bigasterisk.com
parents: 271
diff changeset
39 # frigate build wants to mount a single file from the host, which needs podman 4.5.1
f7178138b736 pkgs and special podman future version
drewp@bigasterisk.com
parents: 271
diff changeset
40 # https://github.com/containers/podman/issues/12123#issuecomment-1620439593
283
drewp@bigasterisk.com
parents: 277
diff changeset
41 apt.deb(src="http://ftp.osuosl.org/pub/ubuntu/pool/universe/libp/libpod/podman_4.9.3+ds1-1_amd64.deb")
drewp@bigasterisk.com
parents: 277
diff changeset
42
205
826db3c40fa7 whitespace/etc
drewp@bigasterisk.com
parents: 203
diff changeset
43
203
3fd439ae1380 minor & some upgrades
drewp@bigasterisk.com
parents: 196
diff changeset
44 def pdm():
206
da0fd5a2ac33 update pdm
drewp@bigasterisk.com
parents: 205
diff changeset
45 # https://github.com/pdm-project/pdm/blob/main/CHANGELOG.md
276
7f79cbbb6f24 updates
drewp@bigasterisk.com
parents: 275
diff changeset
46 server.shell(["pip install --break-system-packages 'pdm==2.12.4'"])
69
659e4b228909 new host 'pipe'
drewp@bigasterisk.com
parents: 62
diff changeset
47
205
826db3c40fa7 whitespace/etc
drewp@bigasterisk.com
parents: 203
diff changeset
48
103
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
49 def proper_locate():
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
50 apt.packages(packages='mlocate', present=False)
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
51 if not is_pi and host.name not in ['prime', 'pipe']:
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
52 apt.packages(packages='plocate')
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
53
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
54
131
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
55 def proper_man():
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
56 if host.name in ['pipe', 'prime'] or is_pi:
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
57 apt.packages(packages=['mandb'], present=False)
12
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
58
205
826db3c40fa7 whitespace/etc
drewp@bigasterisk.com
parents: 203
diff changeset
59
196
c409ea5a1d5c don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents: 192
diff changeset
60 def no_unwanted_services():
c409ea5a1d5c don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents: 192
diff changeset
61 systemd.service(service='nginx', enabled=False, running=False)
c409ea5a1d5c don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents: 192
diff changeset
62
c409ea5a1d5c don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents: 192
diff changeset
63
240
b58f05be720a updates for new ubuntu 23.10 install
drewp@bigasterisk.com
parents: 233
diff changeset
64 kw = dict(present=True, latest=True)
12
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
65
143
6b4226845254 actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents: 138
diff changeset
66 apt.packages(packages=package_lists.setup, **kw)
131
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
67
271
drewp@bigasterisk.com
parents: 268
diff changeset
68
drewp@bigasterisk.com
parents: 268
diff changeset
69 def roblox():
drewp@bigasterisk.com
parents: 268
diff changeset
70 server.shell('flatpak install -y org.freedesktop.Platform/x86_64/23.08')
drewp@bigasterisk.com
parents: 268
diff changeset
71 server.shell('flatpak install -y flathub org.vinegarhq.Vinegar') # (roblox runner)
277
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
72 files.put(
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
73 src=StringIO(
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
74 #"#!/bin/sh\nexec flatpak run org.vinegarhq.Vinegar player run 'roblox-player:1'\n"
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
75 "#!/bin/sh\n exec /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=vinegar org.vinegarhq.Vinegar player run -app\n"
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
76 ),
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
77 dest='/usr/local/bin/roblox.real',
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
78 mode='755')
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
79
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
80 for desktopFile in [
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
81 '/var/lib/flatpak/exports/share/applications/org.vinegarhq.Vinegar.app.desktop',
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
82 '/var/lib/flatpak/app/org.vinegarhq.Vinegar/current/active/export/share/applications/org.vinegarhq.Vinegar.player.desktop',
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
83 ]:
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
84 files.line(path=desktopFile, line="^Exec", replace='Exec=/usr/local/bin/roblox')
ce823a167641 insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents: 276
diff changeset
85 files.link(target='/usr/local/bin/run_while_allowed', path='/usr/local/bin/roblox', force=True)
271
drewp@bigasterisk.com
parents: 268
diff changeset
86
drewp@bigasterisk.com
parents: 268
diff changeset
87
12
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
88 if not is_pi:
83
9e66c3f17351 add reptyr
drewp@bigasterisk.com
parents: 77
diff changeset
89 if host.name != 'pipe':
131
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
90 apt.packages(packages=['reptyr'])
103
8b8ef9d8f0fd dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents: 93
diff changeset
91 kitty()
131
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
92 else:
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
93 apt.packages(packages=package_lists.pi_setup)
12
15c5ce7c74b5 refactor, cleanup, split large deploys
drewp@bigasterisk.com
parents:
diff changeset
94
114
7e280bf26dba package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents: 108
diff changeset
95 proper_locate()
131
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
96 proper_man()
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
97
143
6b4226845254 actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents: 138
diff changeset
98 apt.packages(packages=package_lists.general, **kw)
6b4226845254 actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents: 138
diff changeset
99 apt.packages(packages=package_lists.debug, **kw)
56
4c15fc1e879d bump some tool versions
drewp@bigasterisk.com
parents: 49
diff changeset
100
205
826db3c40fa7 whitespace/etc
drewp@bigasterisk.com
parents: 203
diff changeset
101 if host.name in ["bang", 'ditto']:
146
2065998876e4 add host 'ditto'
drewp@bigasterisk.com
parents: 143
diff changeset
102 apt.packages(packages=package_lists.for_bang_ditto, **kw)
114
7e280bf26dba package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents: 108
diff changeset
103
7e280bf26dba package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents: 108
diff changeset
104 if host.name == "pipe":
143
6b4226845254 actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents: 138
diff changeset
105 apt.packages(packages=package_lists.for_pipe, **kw)
37
fbd0849dfdbd redo networking to be much simpler. Uses systemd-networkd
drewp@bigasterisk.com
parents: 34
diff changeset
106
131
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
107 if host.name == "prime":
143
6b4226845254 actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents: 138
diff changeset
108 apt.packages(packages=package_lists.for_prime, **kw)
131
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
109
37
fbd0849dfdbd redo networking to be much simpler. Uses systemd-networkd
drewp@bigasterisk.com
parents: 34
diff changeset
110 if host.name == 'plus':
143
6b4226845254 actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents: 138
diff changeset
111 apt.packages(packages=package_lists.laptop, **kw)
114
7e280bf26dba package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents: 108
diff changeset
112
268
34ab4aec7d4b notes and changes for getting nvidia gpu k3d support going, which was very hard
drewp@bigasterisk.com
parents: 261
diff changeset
113 if host.name in ['dash', 'slash', 'ditto', 'dot']:
271
drewp@bigasterisk.com
parents: 268
diff changeset
114 apt.packages(packages=package_lists.k8s_node_with_nvidia_gpu(host.name)) # no kw, or apt will remove nvidia-utils-VERS (!)
254
11b738d4c4ae work on k8s/nvidia setup
drewp@bigasterisk.com
parents: 246
diff changeset
115
273
f7178138b736 pkgs and special podman future version
drewp@bigasterisk.com
parents: 271
diff changeset
116 if host.name in ['dash', 'slash', 'ditto']:
283
drewp@bigasterisk.com
parents: 277
diff changeset
117 podman()
273
f7178138b736 pkgs and special podman future version
drewp@bigasterisk.com
parents: 271
diff changeset
118
268
34ab4aec7d4b notes and changes for getting nvidia gpu k3d support going, which was very hard
drewp@bigasterisk.com
parents: 261
diff changeset
119 if host.name == 'ditto':
34ab4aec7d4b notes and changes for getting nvidia gpu k3d support going, which was very hard
drewp@bigasterisk.com
parents: 261
diff changeset
120 # should have happened in the previous step, but it gets reverted.
34ab4aec7d4b notes and changes for getting nvidia gpu k3d support going, which was very hard
drewp@bigasterisk.com
parents: 261
diff changeset
121 apt.packages(packages=['nvidia-utils-535-server'])
131
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
122
7a94db404be4 packages refactor and some updates
drewp@bigasterisk.com
parents: 126
diff changeset
123 if not is_pi:
143
6b4226845254 actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents: 138
diff changeset
124 apt.packages(packages=package_lists.non_pi, **kw)
186
db4b3a07a3dc run pigpiod
drewp@bigasterisk.com
parents: 174
diff changeset
125 else:
db4b3a07a3dc run pigpiod
drewp@bigasterisk.com
parents: 174
diff changeset
126 # move to another file?
205
826db3c40fa7 whitespace/etc
drewp@bigasterisk.com
parents: 203
diff changeset
127 files.template(src="templates/pigpiod.service.j2", dest="/etc/systemd/system/pigpiod.service")
186
db4b3a07a3dc run pigpiod
drewp@bigasterisk.com
parents: 174
diff changeset
128 systemd.service(service='pigpiod', daemon_reload=True, enabled=True)
196
c409ea5a1d5c don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents: 192
diff changeset
129
275
058c312ffdce new host `pillow`
drewp@bigasterisk.com
parents: 273
diff changeset
130 desktop_env = host.name in ['dash', 'slash', 'plus', 'dot', 'squib', 'pillow']
240
b58f05be720a updates for new ubuntu 23.10 install
drewp@bigasterisk.com
parents: 233
diff changeset
131 if desktop_env:
b58f05be720a updates for new ubuntu 23.10 install
drewp@bigasterisk.com
parents: 233
diff changeset
132 apt.packages(packages=package_lists.xorg + package_lists.desktop, **kw)
271
drewp@bigasterisk.com
parents: 268
diff changeset
133 roblox()
261
900402976500 pdm on more hosts
drewp@bigasterisk.com
parents: 255
diff changeset
134 if desktop_env or host.name in ['bang', 'ditto']:
240
b58f05be720a updates for new ubuntu 23.10 install
drewp@bigasterisk.com
parents: 233
diff changeset
135 pdm()
b58f05be720a updates for new ubuntu 23.10 install
drewp@bigasterisk.com
parents: 233
diff changeset
136
205
826db3c40fa7 whitespace/etc
drewp@bigasterisk.com
parents: 203
diff changeset
137 no_unwanted_services()
276
7f79cbbb6f24 updates
drewp@bigasterisk.com
parents: 275
diff changeset
138
7f79cbbb6f24 updates
drewp@bigasterisk.com
parents: 275
diff changeset
139 # todo: ./mrv2-v1.0.8-Linux-amd64.deb