Mercurial > code > home > repos > infra
comparison apt.py @ 282:e10ee3ddadcf
pi changes
author | drewp@bigasterisk.com |
---|---|
date | Mon, 15 Apr 2024 02:27:07 -0700 |
parents | 5c5c314051c5 |
children | 0befc8696a07 |
comparison
equal
deleted
inserted
replaced
281:957eb07e06e6 | 282:e10ee3ddadcf |
---|---|
1 import io | |
1 from pathlib import Path | 2 from pathlib import Path |
2 import shlex | 3 import shlex |
3 from pyinfra import host | 4 from pyinfra import host |
4 from pyinfra.facts.files import FindFiles | 5 from pyinfra.facts.files import FindFiles |
5 from pyinfra.facts.server import Arch, LinuxDistribution | 6 from pyinfra.facts.server import Arch, LinuxDistribution |
6 from pyinfra.operations import apt, files, server | 7 from pyinfra.operations import apt, files, server |
7 | 8 |
8 TZ = 'America/Los_Angeles' | 9 TZ = 'America/Los_Angeles' |
9 | 10 |
10 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] | 11 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] |
12 | |
11 | 13 |
12 def pkg_keys(): | 14 def pkg_keys(): |
13 files.directory(path='/etc/apt/keyrings/') # for raspi | 15 files.directory(path='/etc/apt/keyrings/') # for raspi |
14 for url, name in [ | 16 for url, name in [ |
15 ('https://repo.steampowered.com/steam/archive/stable/steam.gpg', 'steam.gpg'), | 17 ('https://repo.steampowered.com/steam/archive/stable/steam.gpg', 'steam.gpg'), |
41 files.file(path="/etc/apt/trusted.gpg.d/podman.asc", present=False) | 43 files.file(path="/etc/apt/trusted.gpg.d/podman.asc", present=False) |
42 | 44 |
43 # also these | 45 # also these |
44 #-rw-r--r-- 1 root root 2794 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg | 46 #-rw-r--r-- 1 root root 2794 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg |
45 #-rw-r--r-- 1 root root 1733 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg | 47 #-rw-r--r-- 1 root root 1733 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg |
46 | 48 |
47 # raspi needs wget http://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add - | 49 # raspi needs wget http://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add - |
48 | 50 |
49 | 51 |
50 dir = Path('/etc/apt/sources.list.d') | 52 dir = Path('/etc/apt/sources.list.d') |
51 | 53 |
86 # and steam-launcher | 88 # and steam-launcher |
87 | 89 |
88 def flatpak_sources(): | 90 def flatpak_sources(): |
89 server.shell('flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo') | 91 server.shell('flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo') |
90 | 92 |
93 | |
94 def correct_dns(): | |
95 files.put(src=io.StringIO("nameserver 10.2.0.3\n"), dest='/etc/resolv.conf') | |
96 | |
97 | |
98 if is_pi: | |
99 correct_dns() | |
91 pkg_keys() | 100 pkg_keys() |
92 apt_sources() | 101 apt_sources() |
93 flatpak_sources() | 102 flatpak_sources() |