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