bundles/sudo: use sudoers.d
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
c7362df6c4
commit
6ca0d863b1
4 changed files with 17 additions and 16 deletions
5
bundles/sudo/files/bwusers
Normal file
5
bundles/sudo/files/bwusers
Normal file
|
@ -0,0 +1,5 @@
|
|||
% for user, config in sorted(node.metadata['users'].items()):
|
||||
% for p in sorted(config.get('sudo_commands', [])):
|
||||
${user} ALL=(ALL) NOPASSWD:${p}
|
||||
% endfor
|
||||
% endfor
|
|
@ -6,8 +6,4 @@ Defaults secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bi
|
|||
|
||||
root ALL=(ALL) ALL
|
||||
|
||||
% for user, permissions in sorted(node.metadata['sudo'].items()):
|
||||
% for p in sorted(permissions):
|
||||
${user} ALL=(ALL) NOPASSWD:${p}
|
||||
% endfor
|
||||
% endfor
|
||||
#includedir /etc/sudoers.d
|
||||
|
|
|
@ -2,8 +2,19 @@ groups = {
|
|||
'sudo': {},
|
||||
}
|
||||
|
||||
directories = {
|
||||
'/etc/sudoers.d': {
|
||||
'purge': True,
|
||||
},
|
||||
}
|
||||
|
||||
files = {
|
||||
'/etc/sudoers': {
|
||||
'needs': {
|
||||
'file:/etc/sudoers.d/bwusers',
|
||||
},
|
||||
},
|
||||
'/etc/sudoers.d/bwusers': {
|
||||
'content_type': 'mako',
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
@metadata_reactor
|
||||
def sudo_users(metadata):
|
||||
sudoers = {}
|
||||
|
||||
for username, config in metadata.get('users', {}).items():
|
||||
if 'sudo_commands' in config:
|
||||
sudoers[username] = config['sudo_commands']
|
||||
|
||||
return {
|
||||
'sudo': sudoers,
|
||||
}
|
Loading…
Reference in a new issue