Mercurial > code > home > repos > infra
annotate users.py @ 171:5565e4c907aa
add drewp groups; fix logic err
author | drewp@bigasterisk.com |
---|---|
date | Sat, 25 Mar 2023 18:38:53 -0700 |
parents | e18d1a8b1523 |
children | 058c312ffdce |
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 |
3
61945df2a392
updates to work on recent raspbian installs
drewp@bigasterisk.com
parents:
0
diff
changeset
|
5 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
6 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
7 # 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
|
8 # 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
|
9 # different id. |
69 | 10 drewp_gid = 1000 if (not is_pi and host.name != 'pipe') else 501 |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
11 drewp_uid = 501 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
12 drewp_groups = [ |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
13 'lp', 'adm', 'dialout', 'cdrom', 'sudo', 'audio', 'video', 'plugdev', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
14 'games', 'users', 'netdev', 'i2c', 'input', 'spi', 'gpio', 'fuse', |
171 | 15 'docker', 'render', 'mongodb', 'lpadmin' |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
16 ] |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
17 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
18 for group in [ |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
19 'fuse', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
20 'spi', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
21 'gpio', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
22 'i2c', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
23 'input', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
24 'netdev', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
25 'docker', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
26 'render', |
171 | 27 'lpadmin', |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
28 ]: |
72
f0e59adf7b91
updates that aren't pkg or version changes
drewp@bigasterisk.com
parents:
69
diff
changeset
|
29 server.group(group=group, system=True) |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
30 |
171 | 31 svcIds = 1050 |
32 for svc in [ | |
33 # only append to this list: | |
34 "photoprism", | |
35 "mongodb", | |
36 ]: | |
37 server.group(group=svc, gid=svcIds) | |
38 server.user(user=svc, uid=svcIds, group=svc) | |
39 svcIds += 1 | |
40 | |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
41 server.group(group='drewp', gid=drewp_gid) |
145 | 42 # this won't change existing drewp uid; I've been doing that myself. |
86 | 43 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
|
44 |
168 | 45 |
46 | |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
47 if not is_pi: |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
48 server.group(group='adm', gid=4) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
49 server.group(group='cdrom', gid=24) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
50 server.group(group='dialout', gid=20) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
51 server.group(group='dip', gid=30) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
52 server.group(group='lp', gid=7) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
53 # prime has something on 109 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
54 server.group(group='lpadmin', gid=200) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
55 server.group(group='plugdev', gid=46) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
56 server.group(group='docker', system=True) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
57 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
58 server.group(group='damon', gid=3011) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
59 server.group(group='ffg', gid=3008) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
60 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
61 server.user(user='drewp', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
62 uid=drewp_uid, |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
63 group='drewp', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
64 groups=drewp_groups) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
65 |
156 | 66 for name, uid, gid in [ |
67 ('ari', 3019, 3019), | |
68 ('talia', 1003, 1003), | |
69 ]: | |
70 server.group(group=name, gid=gid) | |
71 server.user(user=name, | |
72 uid=uid, | |
73 group=name, | |
50 | 74 groups=['audio', 'dialout', 'docker', 'lp', 'lpadmin', 'sudo', 'video']) |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
75 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
76 server.user(user='ffg', uid=3013, group='ffg') |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
77 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
78 server.user(user='darcsweb') |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
79 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
80 server.user(user='newsbru', uid=1019) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
81 server.user(user='dmcc', uid=1013) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
82 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
83 server.group(group='elastic', gid=3018) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
84 server.user(user='elastic', uid=3018, group='elastic') |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
85 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
86 server.group(group='kelsi', gid=1008) |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
87 server.user(user='kelsi', uid=1008, group='elastic') |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
88 |
72
f0e59adf7b91
updates that aren't pkg or version changes
drewp@bigasterisk.com
parents:
69
diff
changeset
|
89 if host.name != 'pipe': # https://github.com/Fizzadar/pyinfra/issues/835 |
f0e59adf7b91
updates that aren't pkg or version changes
drewp@bigasterisk.com
parents:
69
diff
changeset
|
90 server.group(group='drewnote', gid=1009) |
f0e59adf7b91
updates that aren't pkg or version changes
drewp@bigasterisk.com
parents:
69
diff
changeset
|
91 server.user(user='drewnote', uid=1009) |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
92 |
72
f0e59adf7b91
updates that aren't pkg or version changes
drewp@bigasterisk.com
parents:
69
diff
changeset
|
93 server.group(group='prometheus', gid=1010) |
f0e59adf7b91
updates that aren't pkg or version changes
drewp@bigasterisk.com
parents:
69
diff
changeset
|
94 server.user(user='prometheus', uid=1010) |
0
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
95 |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
96 if is_pi: |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
97 server.group(group='fuse') |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
98 server.user(user='pi', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
99 uid=1000, |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
100 group=7, |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
101 groups=[ |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
102 'lp', 'adm', 'dialout', 'cdrom', 'sudo', 'audio', 'video', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
103 'plugdev', 'games', 'users', 'netdev', 'i2c', 'input', |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
104 'spi', 'gpio', 'fuse', 'docker' |
1550a6db59b3
first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff
changeset
|
105 ]) |