bundles/sudo: change metadata key to 'sudo_commands'

This commit is contained in:
Franzi 2020-09-20 15:11:52 +02:00
parent 04c632953d
commit 577c3c7c49
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 13 additions and 7 deletions

View file

@ -6,6 +6,8 @@ Defaults secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bi
root ALL=(ALL) ALL
% for user in sorted(node.metadata['sudo']):
${user} ALL=(ALL) NOPASSWD:ALL
% for user, permissions in sorted(node.metadata['sudo'].items()):
% for p in sorted(permissions):
${user} ALL=(ALL) NOPASSWD:${p}
% endfor
% endfor

View file

@ -1,10 +1,10 @@
@metadata_reactor
def sudo_users(metadata):
sudoers = set()
sudoers = {}
for username, config in metadata.get('users', {}).items():
if 'sudo' in config and config['sudo']:
sudoers.add(username)
if 'sudo_commands' in config:
sudoers[username] = config['sudo_commands']
return {
'sudo': sudoers,