diff --git a/tasks/__init__.py b/tasks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tasks/tailscale.py b/tasks/tailscale.py index 64839fa..d2939a1 100644 --- a/tasks/tailscale.py +++ b/tasks/tailscale.py @@ -1,17 +1,20 @@ +from pyinfra import host from pyinfra.api import deploy +from pyinfra.facts.files import File from pyinfra.operations import apt from pyinfra.operations import server @deploy def deploy_tailscale(): - server.shell( - name="Install tailscale signing key", - commands=[ - "curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.noarmor.gpg " - "| tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null 2>&1", - ], - ) + if not host.get_fact(File, "/usr/share/keyrings/tailscale-archive-keyring.gpg"): + server.shell( + name="Install tailscale signing key", + commands=[ + "curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.noarmor.gpg " + "| tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null 2>&1", + ], + ) apt.repo( name="Add tailscale repository", src="deb [signed-by=/usr/share/keyrings/tailscale-archive-keyring.gpg] "