Mercurial > code > home > repos > infra
view packages.py @ 254:11b738d4c4ae
work on k8s/nvidia setup
author | drewp@bigasterisk.com |
---|---|
date | Thu, 25 Jan 2024 18:50:44 -0800 |
parents | cb9dce5b0731 |
children | 3f57cb70d592 |
line wrap: on
line source
from pyinfra import host from pyinfra.facts.server import LinuxDistribution from pyinfra.operations import apt, files, server, systemd import package_lists is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] def kitty(): vers = '0.31.0' # see https://github.com/kovidgoyal/kitty/releases home = '/home/drewp' local = f"{home}/.local/kitty" dl = f'/tmp/kitty-{vers}-x86_64.txz' files.download(src=f"https://github.com/kovidgoyal/kitty/releases/download/v{vers}/kitty-{vers}-x86_64.txz", dest=dl) files.directory(local) server.shell([ f"mkdir -p {local}", # https://github.com/Fizzadar/pyinfra/issues/777 f"aunpack --extract-to={local} {dl}", ]) files.link(target="{local}/bin/kitty", path="{home}/bin/kitty") def nodejs(): apt.packages(packages=['libnode72'], present=False, force=True) apt.packages(packages=['nodejs'], latest=True) server.shell([ "rm -f /usr/local/bin/pnp{m,x}", "corepack enable", # https://github.com/pnpm/pnpm/releases # but also https://pnpm.io/installation#compatibility "corepack prepare 'pnpm@8.6.3' --activate", ]) def pdm(): # https://github.com/pdm-project/pdm/blob/main/CHANGELOG.md server.shell(["pip install --break-system-packages 'pdm==2.10.0'"]) def proper_locate(): apt.packages(packages='mlocate', present=False) if not is_pi and host.name not in ['prime', 'pipe']: apt.packages(packages='plocate') def proper_man(): if host.name in ['pipe', 'prime'] or is_pi: apt.packages(packages=['mandb'], present=False) def no_unwanted_services(): systemd.service(service='nginx', enabled=False, running=False) kw = dict(present=True, latest=True) apt.packages(packages=package_lists.setup, **kw) if not is_pi: if host.name != 'pipe': apt.packages(packages=['reptyr']) kitty() else: apt.packages(packages=package_lists.pi_setup) proper_locate() proper_man() apt.packages(packages=package_lists.general, **kw) apt.packages(packages=package_lists.debug, **kw) if host.name in ["bang", 'ditto']: apt.packages(packages=package_lists.for_bang_ditto, **kw) if host.name == "pipe": apt.packages(packages=package_lists.for_pipe, **kw) if host.name == "prime": apt.packages(packages=package_lists.for_prime, **kw) if host.name == 'plus': apt.packages(packages=package_lists.laptop, **kw) if host.name in ['dash', 'bang', 'ditto']: apt.packages(packages=package_lists.k8s_node_with_nvidia_gpu, **kw) if not is_pi: apt.packages(packages=package_lists.non_pi, **kw) if host.name != 'prime': # couldn't get prime to install a newer version than 18.7.0 nodejs() else: # move to another file? files.template(src="templates/pigpiod.service.j2", dest="/etc/systemd/system/pigpiod.service") systemd.service(service='pigpiod', daemon_reload=True, enabled=True) desktop_env = host.name in ['dash', 'slash', 'plus', 'squib'] if desktop_env: apt.packages(packages=package_lists.xorg + package_lists.desktop, **kw) pdm() no_unwanted_services()