annotate apt.py @ 155:522f26c8f691

split apt.py from system.py
author drewp@bigasterisk.com
date Thu, 16 Mar 2023 17:42:17 -0700
parents
children 6ec7cd3615f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
155
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
1 from pyinfra import host
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
2 from pyinfra.facts.files import FindFiles
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
3 from pyinfra.facts.server import Arch, LinuxDistribution
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
4 from pyinfra.operations import apt, files, server
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
5
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
6 TZ = 'America/Los_Angeles'
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
7
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
8 def pkg_keys():
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
9 # apt.key(keyserver='keyserver.ubuntu.com', keyid='04EE7237B7D453EC')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
10 # apt.key(keyserver='keyserver.ubuntu.com', keyid='648ACFD622F3D138')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
11 # apt.key(keyserver='keyserver.ubuntu.com', keyid='8B48AD6246925553')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
12 # apt.key(keyserver='keyserver.ubuntu.com', keyid='F24AEA9FB05498B7')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
13 if host.name != 'prime':
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
14 apt.key(keyserver='keyserver.ubuntu.com', keyid='D0392EC59F9583BA')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
15 apt.key(src='https://dl.google.com/linux/linux_signing_key.pub')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
16 apt.key(src='https://ftp-master.debian.org/keys/archive-key-8-security.asc')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
17 apt.key(src='https://ftp-master.debian.org/keys/archive-key-8.asc')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
18 apt.key(src='https://ftp-master.debian.org/keys/archive-key-9-security.asc')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
19 apt.key(src='https://packages.microsoft.com/keys/microsoft.asc')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
20 apt.key(src='https://deb.nodesource.com/gpgkey/nodesource.gpg.key')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
21 apt.key(src='https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/Release.key')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
22 # Failed to fetch https://repo.steampowered.com/steam/dists/stable/InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F24AEA9FB05498B7
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
23 '''
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
24
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
25
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
26 🚢 ditto(pts/1):/opt# apt update
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
27 Hit:1 http://packages.microsoft.com/repos/code stable InRelease
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
28 Hit:2 http://dl.google.com/linux/chrome/deb stable InRelease
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
29 Get:3 https://repo.steampowered.com/steam stable InRelease [2861 B]
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
30 Hit:4 http://us.archive.ubuntu.com/ubuntu kinetic InRelease
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
31 Get:5 http://us.archive.ubuntu.com/ubuntu kinetic-backports InRelease [99.9 kB]
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
32 Err:3 https://repo.steampowered.com/steam stable InRelease
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
33 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F24AEA9FB05498B7
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
34 Get:6 http://us.archive.ubuntu.com/ubuntu kinetic-security InRelease [109 kB]
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
35 Get:8 http://us.archive.ubuntu.com/ubuntu kinetic-updates InRelease [118 kB]
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
36 Get:9 http://us.archive.ubuntu.com/ubuntu kinetic-updates/universe amd64 Packages [205 kB]
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
37 Get:7 https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04 InRelease [1262 B]
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
38 Get:10 http://us.archive.ubuntu.com/ubuntu kinetic-updates/universe i386 Packages [119 kB]
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
39 Get:11 http://us.archive.ubuntu.com/ubuntu kinetic-updates/universe Translation-en [83.1 kB]
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
40 Err:7 https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04 InRelease
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
41 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4D64390375060AA4
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
42 Reading package lists... Done
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
43 W: http://packages.microsoft.com/repos/code/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
44 W: http://dl.google.com/linux/chrome/deb/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
45 W: GPG error: https://repo.steampowered.com/steam stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F24AEA9FB05498B7
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
46 E: The repository 'https://repo.steampowered.com/steam stable InRelease' is not signed.
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
47 N: Updating from such a repository can't be done securely, and is therefore disabled by default.
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
48 N: See apt-secure(8) manpage for repository creation and user configuration details.
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
49 W: GPG error: https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04 InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4D64390375060AA4
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
50 E: The repository 'https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04 InRelease' is not signed.
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
51 N: Updating from such a repository can't be done securely, and is therefore disabled by default.
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
52 N: See apt-secure(8) manpage for repository creation and user configuration details.
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
53
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
54 '''
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
55 def apt_sources():
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
56 if host.get_fact(Arch) == 'x86_64':
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
57 server.shell(commands=['dpkg --add-architecture i386'])
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
58
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
59 files.template(src='templates/sources.list.j2', dest='/etc/apt/sources.list')
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
60 if host.get_fact(FindFiles, '/etc/apt/sources.list.d/', quote_path=True):
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
61 raise SystemExit(f"new files in {host.name} /etc/apt/sources.list.d/ - please remove")
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
62 apt.packages(update=True,
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
63 cache_time=86400,
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
64 packages=['tzdata'],
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
65 force=True,
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
66 _env={
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
67 'TZ': TZ,
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
68 'LANG': 'en_US.UTF-8',
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
69 'DEBIAN_FRONTEND': 'noninteractive'
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
70 })
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
71 pkg_keys()
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
72 apt_sources()