annotate users.py @ 0:1550a6db59b3

first ported section from ansible. shorter, faster, clearer.
author drewp@bigasterisk.com
date Thu, 04 Nov 2021 00:47:36 -0700
parents
children 61945df2a392
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 is_pi = host.get_fact(LinuxDistribution)['name'] == 'Debian'
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.
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
10 drewp_gid = 1000 if not is_pi else 501
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',
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
15 'docker', 'render'
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',
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
27 ]:
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
28 server.group(group=group)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
29
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
30 server.group(group='drewp', gid=drewp_gid)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
31 server.user(user='drewp', group='drewp', groups=drewp_groups)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
32
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
33 if not is_pi:
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
34 server.group(group='adm', gid=4)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
35 server.group(group='cdrom', gid=24)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
36 server.group(group='dialout', gid=20)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
37 server.group(group='dip', gid=30)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
38 server.group(group='lp', gid=7)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
39 # prime has something on 109
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
40 server.group(group='lpadmin', gid=200)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
41 server.group(group='plugdev', gid=46)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
42 server.group(group='docker', system=True)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
43
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
44 server.group(group='damon', gid=3011)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
45 server.group(group='ffg', gid=3008)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
46
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
47 server.group(group='drewnote', gid=1009)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
48
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
49 server.user(user='drewp',
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
50 uid=drewp_uid,
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
51 group='drewp',
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
52 groups=drewp_groups)
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.group(group='ari', gid=3019)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
55 server.user(user='ari',
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
56 uid=3019,
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
57 group='ari',
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
58 groups=['docker', 'sudo', 'audio', 'video', 'lpadmin', 'lp'])
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
59
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
60 server.user(user='ffg', uid=3013, group='ffg')
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
61
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
62 server.user(user='darcsweb')
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
63
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
64 server.user(user='newsbru', uid=1019)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
65 server.user(user='dmcc', uid=1013)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
66
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
67 server.group(group='elastic', gid=3018)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
68 server.user(user='elastic', uid=3018, group='elastic')
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
69
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
70 server.group(group='kelsi', gid=1008)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
71 server.user(user='kelsi', uid=1008, group='elastic')
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
72
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
73 server.group(group='drewnote', gid=1009)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
74 server.user(user='drewnote', uid=1009)
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.group(group='prometheus', gid=1010)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
77 server.user(user='prometheus', uid=1010)
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
78
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
79 if is_pi:
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
80 server.group(group='fuse')
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
81 server.user(user='pi',
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
82 uid=1000,
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
83 group=7,
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
84 groups=[
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
85 'lp', 'adm', 'dialout', 'cdrom', 'sudo', 'audio', 'video',
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
86 'plugdev', 'games', 'users', 'netdev', 'i2c', 'input',
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
87 'spi', 'gpio', 'fuse', 'docker'
1550a6db59b3 first ported section from ansible. shorter, faster, clearer.
drewp@bigasterisk.com
parents:
diff changeset
88 ])