Mercurial > code > home > repos > infra
annotate users.py @ 313:b3acb9fff274
updates for new ga-iot (pi reformat of host=garage)
author | drewp@bigasterisk.com |
---|---|
date | Mon, 23 Sep 2024 00:32:36 -0700 |
parents | 65e28d2e0cd8 |
children |
rev | line source |
---|---|
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
1 from pyinfra import host |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
2 from pyinfra.operations import server |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
3 from pyinfra.facts.server import LinuxDistribution |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
4 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
5 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
6 # raspbian took 1000 for 'pi' group, but drewp is rarely used on pi |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
7 # setups so hopefully it won't matter much that drew group has a |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
8 # different id. |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
9 drewp_uid, drewp_gid = host.data.drewp_uid, host.data.drewp_gid |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
10 drewp_groups = [ |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
11 'lp', 'adm', 'dialout', 'cdrom', 'sudo', 'audio', 'video', 'plugdev', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
12 'games', 'users', 'netdev', 'i2c', 'input', 'spi', 'gpio', 'fuse', |
313
b3acb9fff274
updates for new ga-iot (pi reformat of host=garage)
drewp@bigasterisk.com
parents:
289
diff
changeset
|
13 'render', 'mongodb', 'lpadmin' |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
14 ] |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
15 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
16 for group in [ |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
17 'fuse', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
18 'spi', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
19 'gpio', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
20 'i2c', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
21 'input', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
22 'netdev', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
23 'render', |
171 | 24 'lpadmin', |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
25 ]: |
72
f0e59adf7b91
updates that aren't pkg or version changes
drewp@bigasterisk.com
parents:
69
diff
changeset
|
26 server.group(group=group, system=True) |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
27 |
171 | 28 svcIds = 1050 |
29 for svc in [ | |
30 # only append to this list: | |
31 "photoprism", | |
32 "mongodb", | |
33 ]: | |
34 server.group(group=svc, gid=svcIds) | |
35 server.user(user=svc, uid=svcIds, group=svc) | |
36 svcIds += 1 | |
37 | |
313
b3acb9fff274
updates for new ga-iot (pi reformat of host=garage)
drewp@bigasterisk.com
parents:
289
diff
changeset
|
38 # the following gets scrambled on new rpi. Run "useradd -u 1501 drewp" as workaround. |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
39 server.group(group='drewp', gid=drewp_gid) |
145 | 40 # this won't change existing drewp uid; I've been doing that myself. |
86 | 41 server.user(user='drewp', uid=drewp_uid, group='drewp', groups=drewp_groups) |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
42 |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
43 if 'pi' not in host.groups: |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
44 server.group(group='adm', gid=4) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
45 server.group(group='cdrom', gid=24) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
46 server.group(group='dialout', gid=20) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
47 server.group(group='dip', gid=30) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
48 server.group(group='lp', gid=7) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
49 # prime has something on 109 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
50 server.group(group='lpadmin', gid=200) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
51 server.group(group='plugdev', gid=46) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
52 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
53 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
54 server.user(user='drewp', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
55 uid=drewp_uid, |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
56 group='drewp', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
57 groups=drewp_groups) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
58 |
156 | 59 for name, uid, gid in [ |
60 ('ari', 3019, 3019), | |
61 ('talia', 1003, 1003), | |
62 ]: | |
63 server.group(group=name, gid=gid) | |
64 server.user(user=name, | |
65 uid=uid, | |
66 group=name, | |
50 | 67 groups=['audio', 'dialout', 'docker', 'lp', 'lpadmin', 'sudo', 'video']) |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
68 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
69 server.user(user='dmcc', uid=1013) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
70 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
71 server.group(group='elastic', gid=3018) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
72 server.user(user='elastic', uid=3018, group='elastic') |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
73 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
74 server.group(group='kelsi', gid=1008) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
75 server.user(user='kelsi', uid=1008, group='elastic') |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
76 |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
77 server.group(group='drewnote', gid=1009) |
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
78 server.user(user='drewnote', uid=1009) |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
79 |
289
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
80 server.group(group='prometheus', gid=1010) |
65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
drewp@bigasterisk.com
parents:
288
diff
changeset
|
81 server.user(user='prometheus', uid=1010) |