support for nethserver users and groups in playbooks
This commit is contained in:
parent
73a1a0ed64
commit
93c6897b34
26
root/etc/ansible/library/nethserver-accounts
Normal file
26
root/etc/ansible/library/nethserver-accounts
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# consider refactoring this script in perl: maybe we can improve the speed
|
||||
# by not calling nethserver scripts (which BTW are wrappers for LDAP queries)
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
# users list
|
||||
cmd = os.popen('/usr/libexec/nethserver/list-users -s -A')
|
||||
userslist = json.loads(cmd.read())
|
||||
|
||||
for u in userslist:
|
||||
cmd = os.popen('/usr/libexec/nethserver/list-user-membership -s -A "' + u + '"')
|
||||
userslist[u]['groups'] = json.loads(cmd.read())
|
||||
|
||||
# groups list
|
||||
cmd = os.popen('/usr/libexec/nethserver/list-groups -s')
|
||||
groupslist = json.loads(cmd.read())
|
||||
|
||||
for g in groupslist:
|
||||
cmd = os.popen('/usr/libexec/nethserver/list-group-members -s "' + g + '"')
|
||||
groupslist[g]['members'] = json.loads(cmd.read())
|
||||
|
||||
# data return
|
||||
print(json.dumps({"groups":groupslist,"users":userslist}))
|
Loading…
x
Reference in New Issue
Block a user