From 3f38497585502d1a3df3e8da42a42c394dcc0de9 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 22 Aug 2021 07:25:46 +0200 Subject: [PATCH] bundles/vmhost: add metadata reactor to add all admins to 'libvirt' group --- bundles/vmhost/metadata.py | 18 ++++++++++++++++++ nodes/home/nas.py | 2 -- nodes/htz/ex42-1048908.py | 7 ------- nodes/rx300.py | 3 --- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/bundles/vmhost/metadata.py b/bundles/vmhost/metadata.py index a01e0dc..f70adc7 100644 --- a/bundles/vmhost/metadata.py +++ b/bundles/vmhost/metadata.py @@ -35,3 +35,21 @@ if node.has_bundle('nftables'): 'pkg_apt:libvirt-daemon-system', }, } + + +@metadata_reactor.provides( + 'users', +) +def libvirt_group_for_admins(metadata): + result = {} + for user, config in metadata.get('users', {}).items(): + if config.get('is_admin', False): + result[user] = { + 'groups': { + 'libvirt', + }, + } + + return { + 'users': result, + } diff --git a/nodes/home/nas.py b/nodes/home/nas.py index ffa49cf..d373ebe 100644 --- a/nodes/home/nas.py +++ b/nodes/home/nas.py @@ -185,13 +185,11 @@ nodes['home.nas'] = { }, 'kunsi': { 'groups': { - 'libvirt', 'nas', }, }, 'sophie': { 'groups': { - 'libvirt', 'nas', }, }, diff --git a/nodes/htz/ex42-1048908.py b/nodes/htz/ex42-1048908.py index 268a5a3..da2c131 100644 --- a/nodes/htz/ex42-1048908.py +++ b/nodes/htz/ex42-1048908.py @@ -72,13 +72,6 @@ nodes['htz.ex42-1048908'] = { '/dev/nvme1', }, }, - 'users': { - 'kunsi': { - 'groups': [ - 'libvirt', - ], - }, - }, 'vm': { 'cpu': 8, 'ram': 64, diff --git a/nodes/rx300.py b/nodes/rx300.py index d926431..aa70124 100644 --- a/nodes/rx300.py +++ b/nodes/rx300.py @@ -496,9 +496,6 @@ nodes['rx300'] = { 'users': { 'kunsi': { 'enable_linger': True, - 'groups': { - 'libvirt', - }, }, }, 'zfs': {