Mercurial > code > home > repos > infra
annotate apt.py @ 189:ef443257ae9c
new host 'squib'
author | drewp@bigasterisk.com |
---|---|
date | Mon, 12 Jun 2023 13:01:59 -0700 |
parents | 087b84e68765 |
children | ee6374edfc06 |
rev | line source |
---|---|
155 | 1 from pyinfra import host |
2 from pyinfra.facts.files import FindFiles | |
3 from pyinfra.facts.server import Arch, LinuxDistribution | |
4 from pyinfra.operations import apt, files, server | |
5 | |
6 TZ = 'America/Los_Angeles' | |
7 | |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
8 |
155 | 9 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
|
10 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
|
11 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
|
12 ('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
|
13 ]: |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
14 files.download(src=url, dest=f'/etc/apt/keyrings/{name}') |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
15 server.shell(commands=[ |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
16 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
|
17 ('https://packages.microsoft.com/keys/microsoft.asc', 'ms.gpg'), |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
18 ('https://deb.nodesource.com/gpgkey/nodesource.gpg.key', 'nodesource.gpg'), |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
19 ('https://dl.google.com/linux/linux_signing_key.pub', 'chrome.gpg'), |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
20 ] |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
21 ]) |
155 | 22 |
23 | |
24 def apt_sources(): | |
25 if host.get_fact(Arch) == 'x86_64': | |
26 server.shell(commands=['dpkg --add-architecture i386']) | |
27 | |
28 files.template(src='templates/sources.list.j2', dest='/etc/apt/sources.list') | |
29 if host.get_fact(FindFiles, '/etc/apt/sources.list.d/', quote_path=True): | |
30 raise SystemExit(f"new files in {host.name} /etc/apt/sources.list.d/ - please remove") | |
31 apt.packages(update=True, | |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
32 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
|
33 packages=['tzdata'], |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
34 force=True, |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
35 _env={ |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
36 'TZ': TZ, |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
37 '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
|
38 'DEBIAN_FRONTEND': 'noninteractive' |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
39 }) |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
40 |
188 | 41 # squib 1st setup seemed to need more updates for node(nodesource) |
42 # 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
|
43 |
155 | 44 pkg_keys() |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
45 apt_sources() |