tasks.py: mypy fixes
This commit is contained in:
parent
20c2373f80
commit
9f3c7b7c80
1 changed files with 15 additions and 14 deletions
29
tasks.py
29
tasks.py
|
@ -6,7 +6,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
from typing import List
|
from typing import Any, List, Union
|
||||||
|
|
||||||
from deploykit import DeployGroup, DeployHost
|
from deploykit import DeployGroup, DeployHost
|
||||||
from invoke import task
|
from invoke import task
|
||||||
|
@ -42,7 +42,7 @@ def deploy_nixos(hosts: List[DeployHost]) -> None:
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def update_sops_files(c):
|
def update_sops_files(c: Any) -> None:
|
||||||
"""
|
"""
|
||||||
Update all sops yaml and json files according to .sops.yaml rules
|
Update all sops yaml and json files according to .sops.yaml rules
|
||||||
"""
|
"""
|
||||||
|
@ -57,7 +57,7 @@ find . \
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def print_keys(c, flake_attr: str) -> None:
|
def print_keys(c: Any, flake_attr: str) -> None:
|
||||||
"""
|
"""
|
||||||
Decrypt host private key, print ssh and age public keys. Use inv print-keys --flake-attr build01
|
Decrypt host private key, print ssh and age public keys. Use inv print-keys --flake-attr build01
|
||||||
"""
|
"""
|
||||||
|
@ -82,7 +82,7 @@ def print_keys(c, flake_attr: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def update_terraform(c):
|
def update_terraform(c: Any) -> None:
|
||||||
"""
|
"""
|
||||||
Update terraform devshell flake
|
Update terraform devshell flake
|
||||||
"""
|
"""
|
||||||
|
@ -103,7 +103,7 @@ git commit --all --amend -m "${commit}" -m "Terraform updates:" -m "${diff}"
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def mkdocs(c):
|
def mkdocs(c: Any) -> None:
|
||||||
"""
|
"""
|
||||||
Serve docs (mkdoc serve)
|
Serve docs (mkdoc serve)
|
||||||
"""
|
"""
|
||||||
|
@ -132,15 +132,15 @@ def get_hosts(hosts: str) -> List[DeployHost]:
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def deploy(c, hosts=""):
|
def deploy(c: Any, hosts: str = "") -> None:
|
||||||
"""
|
"""
|
||||||
Deploy to all servers. Use inv deploy --hosts build01 to deploy to a single server
|
Deploy to all servers. Use inv deploy --hosts build01 to deploy to a single server
|
||||||
"""
|
"""
|
||||||
deploy_nixos(get_hosts(hosts))
|
deploy_nixos(get_hosts(hosts))
|
||||||
|
|
||||||
|
|
||||||
def decrypt_host_key(flake_attr, tmpdir):
|
def decrypt_host_key(flake_attr: str, tmpdir: str) -> None:
|
||||||
def opener(path, flags):
|
def opener(path: str, flags: int) -> Union[str, int]:
|
||||||
return os.open(path, flags, 0o400)
|
return os.open(path, flags, 0o400)
|
||||||
|
|
||||||
t = Path(tmpdir)
|
t = Path(tmpdir)
|
||||||
|
@ -163,7 +163,7 @@ def decrypt_host_key(flake_attr, tmpdir):
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def install(c, flake_attr: str, hostname: str) -> None:
|
def install(c: Any, flake_attr: str, hostname: str) -> None:
|
||||||
"""
|
"""
|
||||||
Decrypt host private key, install with nixos-anywhere. Use inv install --flake-attr build01 --hostname build01.nix-community.org
|
Decrypt host private key, install with nixos-anywhere. Use inv install --flake-attr build01 --hostname build01.nix-community.org
|
||||||
"""
|
"""
|
||||||
|
@ -180,7 +180,7 @@ def install(c, flake_attr: str, hostname: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def build_local(c, hosts=""):
|
def build_local(c: Any, hosts: str = "") -> None:
|
||||||
"""
|
"""
|
||||||
Build all servers. Use inv build-local --hosts build01 to build a single server
|
Build all servers. Use inv build-local --hosts build01 to build a single server
|
||||||
"""
|
"""
|
||||||
|
@ -226,7 +226,7 @@ def wait_for_port(host: str, port: int, shutdown: bool = False) -> None:
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def reboot(c, hosts=""):
|
def reboot(c: Any, hosts: str = "") -> None:
|
||||||
"""
|
"""
|
||||||
Reboot hosts. example usage: inv reboot --hosts build01,build02
|
Reboot hosts. example usage: inv reboot --hosts build01,build02
|
||||||
"""
|
"""
|
||||||
|
@ -235,17 +235,18 @@ def reboot(c, hosts=""):
|
||||||
|
|
||||||
print(f"Wait for {h.host} to shutdown", end="")
|
print(f"Wait for {h.host} to shutdown", end="")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
wait_for_port(h.host, h.port, shutdown=True)
|
port = h.port or 22
|
||||||
|
wait_for_port(h.host, port, shutdown=True)
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
print(f"Wait for {h.host} to start", end="")
|
print(f"Wait for {h.host} to start", end="")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
wait_for_port(h.host, h.port)
|
wait_for_port(h.host, port)
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def cleanup_gcroots(c, hosts=""):
|
def cleanup_gcroots(c: Any, hosts: str = "") -> None:
|
||||||
g = DeployGroup(get_hosts(hosts))
|
g = DeployGroup(get_hosts(hosts))
|
||||||
g.run("sudo find /nix/var/nix/gcroots/auto -type s -delete")
|
g.run("sudo find /nix/var/nix/gcroots/auto -type s -delete")
|
||||||
g.run("sudo systemctl restart nix-gc")
|
g.run("sudo systemctl restart nix-gc")
|
||||||
|
|
Loading…
Add table
Reference in a new issue