Mercurial > code > home > repos > infra
annotate packages/packages.py @ 329:2bbcf00b8d2a
hgignore and reformat
author | drewp@bigasterisk.com |
---|---|
date | Sun, 23 Feb 2025 15:08:58 -0800 |
parents | 5b88b38f2471 |
children |
rev | line source |
---|---|
271 | 1 from io import StringIO |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
2 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
3 from pyinfra.context import host |
186 | 4 from pyinfra.operations import apt, files, server, systemd |
205 | 5 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
6 import packages.package_lists as package_lists |
12 | 7 |
8 | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
9 def kitty(): |
314 | 10 apt.packages(packages=['kitty'], present=False, force=True) |
312 | 11 vers = '0.36.2' # 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
|
12 home = '/home/drewp' |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
13 local = f"{home}/.local/kitty" |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
14 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
|
15 files.download(src=f"https://github.com/kovidgoyal/kitty/releases/download/v{vers}/kitty-{vers}-x86_64.txz", dest=dl) |
288 | 16 files.directory(path=local) |
17 server.shell(commands=[ | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
18 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
|
19 f"aunpack --extract-to={local} {dl}", |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
20 ]) |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
21 files.link(target="{local}/bin/kitty", path="{home}/bin/kitty") |
314 | 22 files.link(target="{local}/bin/kitten", path="{home}/bin/kitten") |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
23 |
12 | 24 |
174
b6b11048d0fb
collect nodejs pkg install stuff together
drewp@bigasterisk.com
parents:
169
diff
changeset
|
25 def nodejs(): |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
26 if 'pi' in host.groups or host.name == 'pipe' or host.name == 'prime': |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
27 return |
174
b6b11048d0fb
collect nodejs pkg install stuff together
drewp@bigasterisk.com
parents:
169
diff
changeset
|
28 apt.packages(packages=['libnode72'], present=False, force=True) |
b6b11048d0fb
collect nodejs pkg install stuff together
drewp@bigasterisk.com
parents:
169
diff
changeset
|
29 apt.packages(packages=['nodejs'], latest=True) |
288 | 30 server.shell(commands=[ |
169 | 31 "rm -f /usr/local/bin/pnp{m,x}", |
32 "corepack enable", | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
33 # https://github.com/pnpm/pnpm/releases |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
34 # but also https://pnpm.io/installation#compatibility |
306 | 35 "corepack prepare 'pnpm@9.8' --activate", |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
36 ]) |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
37 |
283 | 38 |
273
f7178138b736
pkgs and special podman future version
drewp@bigasterisk.com
parents:
271
diff
changeset
|
39 def podman(): |
f7178138b736
pkgs and special podman future version
drewp@bigasterisk.com
parents:
271
diff
changeset
|
40 # 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
|
41 # https://github.com/containers/podman/issues/12123#issuecomment-1620439593 |
288 | 42 server.shell(commands='apt --fix-broken install') |
286 | 43 apt.deb(src="http://ftp.osuosl.org/pub/ubuntu/pool/main/g/gpgme1.0/libgpgme11t64_1.18.0-4.1ubuntu4_amd64.deb") |
288 | 44 server.shell(commands='apt --fix-broken install') |
286 | 45 apt.deb(src="http://ftp.osuosl.org/pub/ubuntu/pool/universe/c/conmon/conmon_2.1.10+ds1-1build2_amd64.deb") |
46 apt.deb(src="http://ftp.osuosl.org/pub/ubuntu/pool/universe/libp/libpod/podman_4.9.3+ds1-1build2_amd64.deb") | |
47 apt.packages(packages=['libsubid4', 'buildah', 'podman-docker'], latest=True) | |
283 | 48 |
205 | 49 |
203 | 50 def pdm(): |
206 | 51 # https://github.com/pdm-project/pdm/blob/main/CHANGELOG.md |
321 | 52 server.shell(commands=["pip install --break-system-packages 'pdm==2.21.0'"]) |
69 | 53 |
205 | 54 |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
55 def proper_locate(): |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
56 apt.packages(packages='mlocate', present=False) |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
57 if 'pi' not in host.groups and host.name not in ['prime', 'pipe']: |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
58 apt.packages(packages='plocate') |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
59 |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
60 |
131 | 61 def proper_man(): |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
62 if 'small' in host.groups or 'pi' in host.groups: |
131 | 63 apt.packages(packages=['mandb'], present=False) |
12 | 64 |
205 | 65 |
196
c409ea5a1d5c
don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents:
192
diff
changeset
|
66 def no_unwanted_services(): |
c409ea5a1d5c
don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents:
192
diff
changeset
|
67 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
|
68 |
c409ea5a1d5c
don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents:
192
diff
changeset
|
69 |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
70 apt.packages(packages=package_lists.setup, latest=True) |
131 | 71 |
271 | 72 |
73 def roblox(): | |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
74 server.shell(commands='flatpak install -y org.freedesktop.Platform/x86_64/23.08') |
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
75 server.shell(commands='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
|
76 files.put( |
ce823a167641
insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents:
276
diff
changeset
|
77 src=StringIO( |
ce823a167641
insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents:
276
diff
changeset
|
78 #"#!/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
|
79 "#!/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
|
80 ), |
ce823a167641
insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents:
276
diff
changeset
|
81 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
|
82 mode='755') |
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 for desktopFile in [ |
ce823a167641
insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents:
276
diff
changeset
|
85 '/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
|
86 '/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
|
87 ]: |
ce823a167641
insert run_while_allowed runner around roblox launcher (although roblox is currently unavailable)
drewp@bigasterisk.com
parents:
276
diff
changeset
|
88 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
|
89 files.link(target='/usr/local/bin/run_while_allowed', path='/usr/local/bin/roblox', force=True) |
271 | 90 |
91 | |
286 | 92 def kube_node(): |
292 | 93 |
94 # avoid having to this workaround: | |
95 # https://longhorn.io/kb/troubleshooting-volume-with-multipath/ | |
96 apt.packages(packages=['multipath-tools'], force=True, present=False) | |
97 | |
286 | 98 apt.packages(packages=[ |
99 # https://longhorn.io/docs/1.6.1/deploy/install/#installation-requirements | |
100 'open-iscsi', | |
101 'nfs-common', | |
292 | 102 'cryptsetup', |
286 | 103 ]) |
104 | |
105 | |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
106 def install_packages(): |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
107 apt.packages(packages=package_lists.general, latest=True) |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
108 apt.packages(packages=package_lists.debug, latest=True) |
131 | 109 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
110 if host.name == "pipe": |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
111 apt.packages(packages=package_lists.for_pipe, latest=True) |
114
7e280bf26dba
package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents:
108
diff
changeset
|
112 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
113 if host.name != 'pipe': |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
114 apt.packages(packages=['reptyr']) |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
115 |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
116 if host.name == "prime": |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
117 apt.packages(packages=package_lists.for_prime, latest=True) |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
118 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
119 if host.name == 'plus': |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
120 apt.packages(packages=package_lists.laptop, latest=True) |
37
fbd0849dfdbd
redo networking to be much simpler. Uses systemd-networkd
drewp@bigasterisk.com
parents:
34
diff
changeset
|
121 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
122 if host.data.get('gpu'): |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
123 apt.packages(packages=package_lists.k8s_node_with_nvidia_gpu(host.name)) |
131 | 124 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
125 if host.data.get('k8s_admin'): |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
126 podman() |
114
7e280bf26dba
package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents:
108
diff
changeset
|
127 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
128 is_kube_node = host.name in ['dash', 'slash', 'ditto', 'ws-printer', 'li-drums'] |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
129 if is_kube_node: |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
130 kube_node() |
273
f7178138b736
pkgs and special podman future version
drewp@bigasterisk.com
parents:
271
diff
changeset
|
131 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
132 if host.name == 'ditto': |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
133 apt.packages(packages=package_lists.for_ditto, latest=True) |
131 | 134 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
135 if 'pi' not in host.groups: |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
136 kitty() |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
137 apt.packages(packages=package_lists.non_pi, latest=True) |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
138 |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
139 if 'pi' in host.groups: |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
140 apt.packages(packages=package_lists.pi_setup) |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
141 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
142 desktop_env = host.name in ['dash', 'slash', 'plus', 'dot', 'squib', 'pillow', 'tofu'] |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
143 if desktop_env: |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
144 apt.packages(packages=package_lists.xorg + package_lists.desktop, latest=True) |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
145 # broken, per https://vinegarhq.org/ |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
146 # roblox() |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
147 if desktop_env or host.name in ['bang', 'ditto']: |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
148 pdm() |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
149 |
196
c409ea5a1d5c
don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents:
192
diff
changeset
|
150 |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
151 operations = [ |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
152 proper_locate, |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
153 proper_man, |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
154 nodejs, |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
155 install_packages, |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
156 no_unwanted_services, |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
323
diff
changeset
|
157 ] |
276 | 158 # todo: ./mrv2-v1.0.8-Linux-amd64.deb |