Mercurial > code > home > repos > infra
annotate 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 |
rev | line source |
---|---|
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
1 from invoke.tasks import task |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
2 |
1 | 3 cmd = ''' |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
4 HOME=/root |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
5 export HOME |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
6 eval `keychain --quiet --eval id_ecdsa` |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
7 cd /my/proj/infra |
202 | 8 pdm run pyinfra ''' |
1 | 9 |
205 | 10 |
139 | 11 def _run(ctx, s): |
325 | 12 ctx.run(cmd + ('--no-wait' * 0) + ' -y inventory.py %s' % s, pty=True, echo=True) |
34
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
13 |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
96
diff
changeset
|
14 |
59
fa7a71b8a97f
more dns checks, including from inside containers in k8s`
drewp@bigasterisk.com
parents:
54
diff
changeset
|
15 @task |
205 | 16 def dns_check(ctx): |
17 _run(ctx, 'dns_check.py -v') | |
18 | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
96
diff
changeset
|
19 |
68 | 20 @task |
205 | 21 def dns_k8s_check(ctx): |
288 | 22 ctx.run('pdm run python dns_k8s_check.py', pty=True) |
205 | 23 |
8 | 24 |
14 | 25 @task |
205 | 26 def multikube(ctx): # danger- wipes previous k3s |
111 | 27 from multikube_config import server_node, nodes |
28 ctx.run(cmd + 'inventory.py multikube_wipe.py', pty=True) | |
29 ctx.run(cmd + f'inventory.py multikube.py --limit {server_node}', pty=True) | |
113
c520672d0930
closer to multi-node k3s working, but still doesn't quite network right
drewp@bigasterisk.com
parents:
111
diff
changeset
|
30 if nodes: |
136
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
31 ctx.run(cmd + f'inventory.py multikube.py {" ".join(f"--limit {n}" for n in nodes)}', pty=True) |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
32 print("""now try |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
33 curl http://10.43.0.10:9153/metrics | head |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
34 k3s kubectl run hello --image crccheck/hello-world |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
35 curl -m2 http://`kubectl get pod/hello '-o=jsonpath={.status.podIP}'`:8000 |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
36 """) |
111 | 37 |
16 | 38 |
60 | 39 @task |
54 | 40 def all(ctx): |
326
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
41 for opGroup in [ |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
42 'users', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
43 'system', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
44 'apt', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
45 'packages', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
46 'net', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
47 'dns', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
48 'wireguard', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
49 'kube', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
50 'sync', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
51 'mail', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
52 'home', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
53 ]: |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
54 ctx.run( |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
55 ' '.join([ |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
56 cmd, #'--no-wait', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
57 '-y', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
58 'inventory.py', |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
59 'all_operations.py' |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
60 ]), |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
61 pty=True, |
5b88b38f2471
huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
325
diff
changeset
|
62 env={'GROUP': opGroup}) |
54 | 63 ctx.run('touch /my/proj/infra/ran_all.timestamp') |
64 | |
65 | |
16 | 66 @task |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
67 def get_fact(ctx, host='dash', fact='server.LinuxDistribution'): |
8 | 68 ctx.run(cmd + f'{host} -vv fact {fact}', pty=True) |