Mercurial > code > home > repos > infra
annotate tasks.py @ 60:a949704defd0
new pyinfra
author | drewp@bigasterisk.com |
---|---|
date | Sun, 01 May 2022 23:31:20 -0700 |
parents | fa7a71b8a97f |
children | b46df76991b6 |
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 |
50 | 3 |
1 | 4 cmd = ''' |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
5 HOME=/root |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
6 export HOME |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
7 eval `keychain --quiet --eval id_ecdsa` |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
8 cd /my/proj/infra |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
9 env/bin/pyinfra ''' |
1 | 10 |
5 | 11 |
1 | 12 @task |
13 def users(ctx): | |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
14 ctx.run(cmd + 'inventory.py users.py', pty=True) |
1 | 15 |
5 | 16 |
1 | 17 @task |
12 | 18 def ssh(ctx): |
19 ctx.run(cmd + 'inventory.py ssh.py', pty=True) | |
20 | |
21 | |
22 @task | |
1 | 23 def system(ctx): |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
24 ctx.run(cmd + 'inventory.py system.py', pty=True) |
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
25 |
5 | 26 |
27 @task | |
12 | 28 def packages(ctx): |
29 ctx.run(cmd + 'inventory.py packages.py', pty=True) | |
30 | |
31 | |
32 @task | |
7
b6fff51f8676
net.py setup. May not be safe on bang yet
drewp@bigasterisk.com
parents:
5
diff
changeset
|
33 def net(ctx): |
40 | 34 ctx.run(cmd + 'inventory.py net.py -v', pty=True) |
7
b6fff51f8676
net.py setup. May not be safe on bang yet
drewp@bigasterisk.com
parents:
5
diff
changeset
|
35 |
b6fff51f8676
net.py setup. May not be safe on bang yet
drewp@bigasterisk.com
parents:
5
diff
changeset
|
36 |
b6fff51f8676
net.py setup. May not be safe on bang yet
drewp@bigasterisk.com
parents:
5
diff
changeset
|
37 @task |
34
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
38 def dns(ctx): |
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
39 ctx.run(cmd + 'inventory.py dns.py -v', pty=True) |
45 | 40 ctx.run(cmd + 'inventory.py dns_check.py -v', pty=True) |
41 | |
42 @task | |
43 def dns_check(ctx): | |
44 ctx.run(cmd + 'inventory.py dns_check.py -v', pty=True) | |
34
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
45 |
59
fa7a71b8a97f
more dns checks, including from inside containers in k8s`
drewp@bigasterisk.com
parents:
54
diff
changeset
|
46 @task |
fa7a71b8a97f
more dns checks, including from inside containers in k8s`
drewp@bigasterisk.com
parents:
54
diff
changeset
|
47 def dns_k8s_check(ctx): |
fa7a71b8a97f
more dns checks, including from inside containers in k8s`
drewp@bigasterisk.com
parents:
54
diff
changeset
|
48 ctx.run('env/bin/python dns_k8s_check.py', pty=True) |
fa7a71b8a97f
more dns checks, including from inside containers in k8s`
drewp@bigasterisk.com
parents:
54
diff
changeset
|
49 |
34
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
50 |
d4fb38f13c79
refactor dns and some other non-net setup
drewp@bigasterisk.com
parents:
23
diff
changeset
|
51 @task |
5 | 52 def wireguard(ctx): |
53 ctx.run(cmd + 'inventory.py wireguard.py', pty=True) | |
54 | |
55 | |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
56 @task |
8 | 57 def kube(ctx): |
45 | 58 ctx.run(cmd + 'inventory.py kube.py -vv ', pty=True) |
12 | 59 |
8 | 60 |
14 | 61 @task |
62 def sync(ctx): | |
63 ctx.run(cmd + 'inventory.py sync.py ', pty=True) | |
64 | |
8 | 65 |
66 @task | |
16 | 67 def mail(ctx): |
45 | 68 ctx.run(cmd + 'inventory.py mail.py ', pty=True) |
16 | 69 |
70 | |
60 | 71 @task |
54 | 72 def all(ctx): |
60 | 73 configs = [ |
74 'users.py', | |
75 'ssh.py', | |
76 'system.py', | |
77 'packages.py', | |
78 'net.py', | |
79 'dns.py', | |
80 'wireguard.py', | |
81 'kube.py', | |
82 'sync.py', | |
83 'mail.py', | |
84 ] | |
85 # https://github.com/Fizzadar/pyinfra/issues/787 | |
86 #ctx.run(' '.join([cmd, 'inventory.py'] + configs), pty=True) | |
87 for c in configs: | |
88 ctx.run(' '.join([cmd, 'inventory.py', c]), pty=True, warn=True) | |
54 | 89 ctx.run('touch /my/proj/infra/ran_all.timestamp') |
90 | |
91 | |
16 | 92 @task |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
1
diff
changeset
|
93 def get_fact(ctx, host='dash', fact='server.LinuxDistribution'): |
8 | 94 ctx.run(cmd + f'{host} -vv fact {fact}', pty=True) |