Mercurial > code > home > repos > infra
comparison apt.py @ 288:3af02e24eaf9
minor
author | drewp@bigasterisk.com |
---|---|
date | Sun, 21 Apr 2024 17:01:13 -0700 |
parents | 73ec5064da44 |
children | 65e28d2e0cd8 |
comparison
equal
deleted
inserted
replaced
287:c094d23b7943 | 288:3af02e24eaf9 |
---|---|
1 import io | 1 import io |
2 from pathlib import Path | 2 from pathlib import Path |
3 import shlex | 3 import shlex |
4 from typing import cast | |
4 from pyinfra import host | 5 from pyinfra import host |
5 from pyinfra.facts.files import FindFiles | 6 from pyinfra.facts.files import FindFiles |
6 from pyinfra.facts.server import Arch, LinuxDistribution | 7 from pyinfra.facts.server import Arch, LinuxDistribution |
7 from pyinfra.operations import apt, files, server | 8 from pyinfra.operations import apt, files, server |
8 | 9 |
58 dir / 'steam-beta.list', | 59 dir / 'steam-beta.list', |
59 dir / 'google-chrome-unstable.list', | 60 dir / 'google-chrome-unstable.list', |
60 dir / 'steam-stable.list', | 61 dir / 'steam-stable.list', |
61 dir / 'raspi.list', | 62 dir / 'raspi.list', |
62 ]): | 63 ]): |
63 found = map(Path, host.get_fact(FindFiles, dir, quote_path=True)) | 64 found = map(Path, cast(str, host.get_fact(FindFiles, dir, quote_path=True))) |
64 if set(found) - set(known): | 65 if set(found) - set(known): |
65 raise SystemExit(f"new files in {host.name} /etc/apt/sources.list.d/ - please remove") | 66 raise SystemExit(f"new files in {host.name} /etc/apt/sources.list.d/ - please remove") |
66 for f in known: | 67 for f in known: |
67 files.file(path=f, present=False) | 68 files.file(path=f, present=False) |
68 | 69 |
88 # and steam-launcher | 89 # and steam-launcher |
89 | 90 |
90 | 91 |
91 def flatpak_sources(): | 92 def flatpak_sources(): |
92 apt.packages(update=True, cache_time=86400, packages=['flatpak']) | 93 apt.packages(update=True, cache_time=86400, packages=['flatpak']) |
93 server.shell('flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo') | 94 server.shell(commands='flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo') |
94 | 95 |
95 | 96 |
96 def correct_dns(): | 97 def correct_dns(): |
97 files.put(src=io.StringIO("nameserver 10.2.0.3\n"), dest='/etc/resolv.conf') | 98 files.put(src=io.StringIO("nameserver 10.2.0.3\n"), dest='/etc/resolv.conf') |
98 | 99 |