Mercurial > code > home > repos > infra
annotate apt.py @ 240:b58f05be720a
updates for new ubuntu 23.10 install
author | drewp@bigasterisk.com |
---|---|
date | Mon, 11 Dec 2023 21:22:12 -0800 |
parents | 19a7f714273c |
children | ff36727f3a10 |
rev | line source |
---|---|
195 | 1 from pathlib import Path |
155 | 2 from pyinfra import host |
3 from pyinfra.facts.files import FindFiles | |
4 from pyinfra.facts.server import Arch, LinuxDistribution | |
5 from pyinfra.operations import apt, files, server | |
6 | |
7 TZ = 'America/Los_Angeles' | |
8 | |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
9 |
155 | 10 def pkg_keys(): |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
11 files.directory(path='/etc/apt/keyrings/') # for raspi |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
12 for url, name in [ |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
13 ('https://repo.steampowered.com/steam/archive/stable/steam.gpg', 'steam.gpg'), |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
14 ]: |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
15 files.download(src=url, dest=f'/etc/apt/keyrings/{name}') |
203 | 16 |
17 # vscode keeps making this, but I fetch my own | |
235
19a7f714273c
pkg updates, take out nvidia drv for now
drewp@bigasterisk.com
parents:
230
diff
changeset
|
18 files.file(path='/etc/apt/trusted.gpg.d/microsoft.gpg', present=False) |
203 | 19 |
230 | 20 # and it makes this, which is redundant with my sources.list template line |
21 files.file(path='/etc/apt/sources.list.d/vscode.list', present=False) | |
22 | |
240 | 23 apt.packages(packages=['curl']) |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
24 server.shell(commands=[ |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
25 f"curl -fsSL {url} | gpg --dearmor > /etc/apt/keyrings/{name}" for (url, name) in [ |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
26 ('https://packages.microsoft.com/keys/microsoft.asc', 'ms.gpg'), |
240 | 27 ('https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key', 'nodesource.gpg'), |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
28 ('https://dl.google.com/linux/linux_signing_key.pub', 'chrome.gpg'), |
195 | 29 ('https://ftp-master.debian.org/keys/archive-key-11.asc', 'bullseye.gpg'), |
30 ('https://ftp-master.debian.org/keys/archive-key-11-security.asc', 'bullseye-security.gpg'), | |
209 | 31 ('https://packages.cloud.google.com/apt/doc/apt-key.gpg', 'coral.gpg'), |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
32 ] |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
33 ]) |
195 | 34 if host.get_fact(Arch) == 'armv7l' or host.name == 'bang': # I mean raspbian/debian |
35 # this contaminates the apt-update | |
36 files.file(path="/etc/apt/trusted.gpg.d/podman.asc", present=False) | |
37 | |
211 | 38 # also these |
39 #-rw-r--r-- 1 root root 2794 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg | |
40 #-rw-r--r-- 1 root root 1733 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg | |
195 | 41 |
42 dir = Path('/etc/apt/sources.list.d') | |
43 | |
44 | |
240 | 45 def clear_known_sources_files(known=[ |
46 dir / 'vscode.list', | |
47 dir / 'google-chrome.list', | |
48 dir / 'steam-beta.list', | |
49 dir / 'google-chrome-unstable.list', | |
50 dir / 'steam-stable.list', | |
51 ]): | |
195 | 52 found = map(Path, host.get_fact(FindFiles, dir, quote_path=True)) |
53 if set(found) - set(known): | |
54 raise SystemExit(f"new files in {host.name} /etc/apt/sources.list.d/ - please remove") | |
55 for f in known: | |
56 files.file(path=f, present=False) | |
155 | 57 |
58 | |
59 def apt_sources(): | |
60 if host.get_fact(Arch) == 'x86_64': | |
61 server.shell(commands=['dpkg --add-architecture i386']) | |
62 | |
63 files.template(src='templates/sources.list.j2', dest='/etc/apt/sources.list') | |
195 | 64 |
65 clear_known_sources_files() | |
155 | 66 apt.packages(update=True, |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
67 cache_time=86400, |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
68 packages=['tzdata'], |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
69 force=True, |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
70 _env={ |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
71 'TZ': TZ, |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
72 'LANG': 'en_US.UTF-8', |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
73 'DEBIAN_FRONTEND': 'noninteractive' |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
74 }) |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
75 |
188 | 76 # squib 1st setup seemed to need more updates for node(nodesource) |
77 # and steam-launcher | |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
78 |
195 | 79 |
155 | 80 pkg_keys() |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
81 apt_sources() |