Mercurial > code > home > repos > infra
comparison apt.py @ 289:65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
author | drewp@bigasterisk.com |
---|---|
date | Sun, 21 Apr 2024 17:07:23 -0700 |
parents | 3af02e24eaf9 |
children | d000aead76d4 |
comparison
equal
deleted
inserted
replaced
288:3af02e24eaf9 | 289:65e28d2e0cd8 |
---|---|
6 from pyinfra.facts.files import FindFiles | 6 from pyinfra.facts.files import FindFiles |
7 from pyinfra.facts.server import Arch, LinuxDistribution | 7 from pyinfra.facts.server import Arch, LinuxDistribution |
8 from pyinfra.operations import apt, files, server | 8 from pyinfra.operations import apt, files, server |
9 | 9 |
10 TZ = 'America/Los_Angeles' | 10 TZ = 'America/Los_Angeles' |
11 | |
12 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] | |
13 | 11 |
14 | 12 |
15 def pkg_keys(): | 13 def pkg_keys(): |
16 files.directory(path='/etc/apt/keyrings/') # for raspi | 14 files.directory(path='/etc/apt/keyrings/') # for raspi |
17 for url, name in [ | 15 for url, name in [ |
37 ('https://packages.cloud.google.com/apt/doc/apt-key.gpg', 'coral.gpg'), | 35 ('https://packages.cloud.google.com/apt/doc/apt-key.gpg', 'coral.gpg'), |
38 ('https://hub.unity3d.com/linux/keys/public', 'unityhub.gpg'), | 36 ('https://hub.unity3d.com/linux/keys/public', 'unityhub.gpg'), |
39 ('https://nvidia.github.io/libnvidia-container/gpgkey', 'nvidia.gpg'), | 37 ('https://nvidia.github.io/libnvidia-container/gpgkey', 'nvidia.gpg'), |
40 ] | 38 ] |
41 ]) | 39 ]) |
42 if is_pi or host.name == 'bang': | 40 if 'pi' in host.groups or host.name == 'bang': |
43 # this contaminates the apt-update | 41 # this contaminates the apt-update |
44 files.file(path="/etc/apt/trusted.gpg.d/podman.asc", present=False) | 42 files.file(path="/etc/apt/trusted.gpg.d/podman.asc", present=False) |
45 | 43 |
46 # also these | 44 # also these |
47 #-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 2794 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg |
96 | 94 |
97 def correct_dns(): | 95 def correct_dns(): |
98 files.put(src=io.StringIO("nameserver 10.2.0.3\n"), dest='/etc/resolv.conf') | 96 files.put(src=io.StringIO("nameserver 10.2.0.3\n"), dest='/etc/resolv.conf') |
99 | 97 |
100 | 98 |
101 if is_pi: | 99 if 'pi' in host.groups: |
102 correct_dns() | 100 correct_dns() |
103 pkg_keys() | 101 pkg_keys() |
104 apt_sources() | 102 apt_sources() |
105 flatpak_sources() | 103 flatpak_sources() |