Mercurial > code > home > repos > infra
annotate tasks.py @ 191:d7ddfe3837b0
syncthing clients update
author | drewp@bigasterisk.com |
---|---|
date | Mon, 12 Jun 2023 13:07:42 -0700 |
parents | 522f26c8f691 |
children | a5399e8b47b6 |
rev | line source |
---|---|
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
1 from invoke import task |
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 |
149 | 8 ~drewp/bin/pdm run pyinfra ''' |
1 | 9 |
139 | 10 def _run(ctx, s): |
11 ctx.run(cmd + '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
|
12 |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
96
diff
changeset
|
13 |
59
fa7a71b8a97f
more dns checks, including from inside containers in k8s`
drewp@bigasterisk.com
parents:
54
diff
changeset
|
14 @task |
139 | 15 def users(ctx): _run(ctx, 'users.py') |
59
fa7a71b8a97f
more dns checks, including from inside containers in k8s`
drewp@bigasterisk.com
parents:
54
diff
changeset
|
16 |
139 | 17 @task |
18 def ssh(ctx): _run(ctx, 'ssh.py') | |
19 | |
20 @task | |
145 | 21 def system(ctx): _run(ctx, 'system.py') |
34
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
22 |
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
23 @task |
155 | 24 def apt(ctx): _run(ctx, 'apt.py') |
25 | |
26 @task | |
145 | 27 def packages(ctx): _run(ctx, 'packages.py') |
5 | 28 |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
29 @task |
139 | 30 def net(ctx): _run(ctx, 'net.py') |
12 | 31 |
139 | 32 @task |
33 def dns(ctx): _run(ctx, 'dns.py') | |
34 | |
35 @task | |
36 def dns_check(ctx): _run(ctx, 'dns_check.py -v') | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
96
diff
changeset
|
37 |
68 | 38 @task |
139 | 39 def dns_k8s_check(ctx): ctx.run('env/bin/python dns_k8s_check.py', pty=True) |
8 | 40 |
14 | 41 @task |
139 | 42 def wireguard(ctx): _run(ctx, 'wireguard.py') |
14 | 43 |
139 | 44 @task |
45 def kube(ctx): _run(ctx, 'kube.py') | |
8 | 46 |
47 @task | |
139 | 48 def kube_bang(ctx): _run(ctx, 'kube.py --limit bang') |
16 | 49 |
139 | 50 @task |
51 def sync(ctx): _run(ctx, 'sync.py') | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
96
diff
changeset
|
52 |
96
b70070570e10
new task for building ntop from source
drewp@bigasterisk.com
parents:
72
diff
changeset
|
53 @task |
139 | 54 def mail(ctx): _run(ctx, 'mail.py') |
110 | 55 |
56 @task | |
139 | 57 def home(ctx): _run(ctx, 'home.py') |
58 | |
59 @task | |
60 def pipe(ctx): ctx.run(cmd + 'inventory.py pipe.py --limit pipe', pty=True) | |
96
b70070570e10
new task for building ntop from source
drewp@bigasterisk.com
parents:
72
diff
changeset
|
61 |
111 | 62 @task |
115 | 63 def multikube(ctx): # danger- wipes previous k3s |
111 | 64 from multikube_config import server_node, nodes |
65 ctx.run(cmd + 'inventory.py multikube_wipe.py', pty=True) | |
66 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
|
67 if nodes: |
136
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
68 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
|
69 print("""now try |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
70 curl http://10.43.0.10:9153/metrics | head |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
71 k3s kubectl run hello --image crccheck/hello-world |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
72 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
|
73 """) |
111 | 74 |
16 | 75 |
60 | 76 @task |
54 | 77 def all(ctx): |
60 | 78 configs = [ |
79 'users.py', | |
80 'ssh.py', | |
81 'system.py', | |
155 | 82 'apt.py', |
60 | 83 'packages.py', |
84 'net.py', | |
85 'dns.py', | |
86 'wireguard.py', | |
87 'kube.py', | |
88 'sync.py', | |
89 'mail.py', | |
110 | 90 'home.py', |
60 | 91 ] |
92 # https://github.com/Fizzadar/pyinfra/issues/787 | |
93 #ctx.run(' '.join([cmd, 'inventory.py'] + configs), pty=True) | |
94 for c in configs: | |
126
fe3ae7c95e65
collect all apt/sources.list into a central template
drewp@bigasterisk.com
parents:
115
diff
changeset
|
95 ctx.run(' '.join([cmd, 'inventory.py', c]), pty=True) |
54 | 96 ctx.run('touch /my/proj/infra/ran_all.timestamp') |
97 | |
98 | |
16 | 99 @task |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
100 def get_fact(ctx, host='dash', fact='server.LinuxDistribution'): |
8 | 101 ctx.run(cmd + f'{host} -vv fact {fact}', pty=True) |