Mercurial > code > home > repos > infra
view tasks.py @ 332:d4893670f888 default tip
WIP: use watchdog reboot timer on pi
author | drewp@bigasterisk.com |
---|---|
date | Thu, 27 Feb 2025 11:09:29 -0800 |
parents | 5b88b38f2471 |
children |
line wrap: on
line source
from invoke.tasks import task cmd = ''' HOME=/root export HOME eval `keychain --quiet --eval id_ecdsa` cd /my/proj/infra pdm run pyinfra ''' def _run(ctx, s): ctx.run(cmd + ('--no-wait' * 0) + ' -y inventory.py %s' % s, pty=True, echo=True) @task def dns_check(ctx): _run(ctx, 'dns_check.py -v') @task def dns_k8s_check(ctx): ctx.run('pdm run python dns_k8s_check.py', pty=True) @task def multikube(ctx): # danger- wipes previous k3s from multikube_config import server_node, nodes ctx.run(cmd + 'inventory.py multikube_wipe.py', pty=True) ctx.run(cmd + f'inventory.py multikube.py --limit {server_node}', pty=True) if nodes: ctx.run(cmd + f'inventory.py multikube.py {" ".join(f"--limit {n}" for n in nodes)}', pty=True) print("""now try curl http://10.43.0.10:9153/metrics | head k3s kubectl run hello --image crccheck/hello-world curl -m2 http://`kubectl get pod/hello '-o=jsonpath={.status.podIP}'`:8000 """) @task def all(ctx): for opGroup in [ 'users', 'system', 'apt', 'packages', 'net', 'dns', 'wireguard', 'kube', 'sync', 'mail', 'home', ]: ctx.run( ' '.join([ cmd, #'--no-wait', '-y', 'inventory.py', 'all_operations.py' ]), pty=True, env={'GROUP': opGroup}) ctx.run('touch /my/proj/infra/ran_all.timestamp') @task def get_fact(ctx, host='dash', fact='server.LinuxDistribution'): ctx.run(cmd + f'{host} -vv fact {fact}', pty=True)