Mercurial > code > home > repos > infra
annotate tasks.py @ 320:11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
author | drewp@bigasterisk.com |
---|---|
date | Fri, 08 Nov 2024 23:16:56 -0800 |
parents | 2d20824d8e8b |
children | 4d1b6a6e65d2 |
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 |
202 | 8 pdm run pyinfra ''' |
1 | 9 |
205 | 10 |
139 | 11 def _run(ctx, s): |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
315
diff
changeset
|
12 ctx.run(cmd + '--no-wait -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 users(ctx): |
17 _run(ctx, 'users.py') | |
18 | |
59
fa7a71b8a97f
more dns checks, including from inside containers in k8s`
drewp@bigasterisk.com
parents:
54
diff
changeset
|
19 |
139 | 20 @task |
205 | 21 def ssh(ctx): |
22 _run(ctx, 'ssh.py') | |
23 | |
139 | 24 |
25 @task | |
205 | 26 def system(ctx): |
27 _run(ctx, 'system.py') | |
28 | |
34
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
29 |
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
30 @task |
205 | 31 def apt(ctx): |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
315
diff
changeset
|
32 _run(ctx, 'apt/apt.py') |
205 | 33 |
155 | 34 |
35 @task | |
205 | 36 def packages(ctx): |
37 _run(ctx, 'packages.py') | |
38 | |
5 | 39 |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
40 @task |
205 | 41 def net(ctx): |
42 _run(ctx, 'net.py') | |
43 | |
12 | 44 |
139 | 45 @task |
205 | 46 def dns(ctx): |
47 _run(ctx, 'dns.py') | |
48 | |
139 | 49 |
50 @task | |
205 | 51 def dns_check(ctx): |
52 _run(ctx, 'dns_check.py -v') | |
53 | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
96
diff
changeset
|
54 |
68 | 55 @task |
205 | 56 def dns_k8s_check(ctx): |
288 | 57 ctx.run('pdm run python dns_k8s_check.py', pty=True) |
205 | 58 |
8 | 59 |
14 | 60 @task |
205 | 61 def wireguard(ctx): |
62 _run(ctx, 'wireguard.py') | |
63 | |
14 | 64 |
139 | 65 @task |
205 | 66 def kube(ctx): |
67 _run(ctx, 'kube.py') | |
68 | |
8 | 69 |
70 @task | |
205 | 71 def sync(ctx): |
72 _run(ctx, 'sync.py') | |
73 | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
96
diff
changeset
|
74 |
96
b70070570e10
new task for building ntop from source
drewp@bigasterisk.com
parents:
72
diff
changeset
|
75 @task |
205 | 76 def mail(ctx): |
77 _run(ctx, 'mail.py') | |
78 | |
110 | 79 |
80 @task | |
205 | 81 def home(ctx): |
82 _run(ctx, 'home.py') | |
83 | |
139 | 84 |
85 @task | |
205 | 86 def multikube(ctx): # danger- wipes previous k3s |
111 | 87 from multikube_config import server_node, nodes |
88 ctx.run(cmd + 'inventory.py multikube_wipe.py', pty=True) | |
89 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
|
90 if nodes: |
136
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
91 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
|
92 print("""now try |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
93 curl http://10.43.0.10:9153/metrics | head |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
94 k3s kubectl run hello --image crccheck/hello-world |
375515ab60ba
multikube experiment junk. do not run
drewp@bigasterisk.com
parents:
126
diff
changeset
|
95 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
|
96 """) |
111 | 97 |
16 | 98 |
60 | 99 @task |
54 | 100 def all(ctx): |
60 | 101 configs = [ |
102 'users.py', | |
103 'ssh.py', | |
104 'system.py', | |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
315
diff
changeset
|
105 'apt/apt.py', |
60 | 106 'packages.py', |
107 'net.py', | |
108 'dns.py', | |
109 'wireguard.py', | |
110 'kube.py', | |
111 'sync.py', | |
112 'mail.py', | |
110 | 113 'home.py', |
60 | 114 ] |
315 | 115 ctx.run(' '.join([cmd, '--no-wait', '-y', 'inventory.py'] + configs), pty=True) |
54 | 116 ctx.run('touch /my/proj/infra/ran_all.timestamp') |
117 | |
118 | |
16 | 119 @task |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
120 def get_fact(ctx, host='dash', fact='server.LinuxDistribution'): |
8 | 121 ctx.run(cmd + f'{host} -vv fact {fact}', pty=True) |