remove users/$user/is_admin metadata, directly write sudo_commands instead

This commit is contained in:
Franzi 2024-02-25 15:29:10 +01:00
parent 02e25f89ff
commit 7d4624ce62
Signed by: kunsi
GPG key ID: 12E3D2136B818350
7 changed files with 8 additions and 26 deletions

View file

@ -1,9 +1,5 @@
% for user, config in sorted(node.metadata['users'].items()):
% if config.get('is_admin', False):
${user} ALL=(ALL) NOPASSWD:ALL
% else:
% for p in sorted(config.get('sudo_commands', [])):
% for p in sorted(config.get('sudo_commands', [])):
${user} ALL=(ALL) NOPASSWD:${p}
% endfor
% endif
% endfor
% endfor

View file

@ -36,7 +36,7 @@ def add_users_from_json(metadata):
if config.get('is_admin', False) or uname in metadata_users:
users[uname] = {
'ssh_pubkey': set(config['ssh_pubkey']),
'is_admin': config.get('is_admin', False),
'sudo_commands': ['ALL'],
}
# Then, run again to get all 'to be deleted' users

View file

@ -52,7 +52,7 @@ if node.has_bundle('arch-with-gui'):
def libvirt_group_for_admins(metadata):
result = {}
for user, config in metadata.get('users', {}).items():
if config.get('is_admin', False):
if 'ALL' in config.get('sudo_commands', set()):
result[user] = {
'groups': {
'libvirt',