import subprocess import os import glob def runAnsiblePlaybook(config, key, branch): subprocess.run(['ansible-playbook', config['ansiblemenu'][key]['playbook']], check=True, cwd=config['base_path']) def addLocalAdmin(config, user): result = subprocess.run( ['ansible-playbook', 'ansible/configure-local-admin.yml', '--extra-vars', str({'user': user, 'state': 'present'})], check=True) def removeLocalAdmin(config, user): result = subprocess.run( ['ansible-playbook', 'ansible/configure-local-admin.yml', '--extra-vars', str({'user': user, 'state': 'absent'})], check=True) def getLocalAdmins(config): prefix = '/etc/sudoers.d/libreticmenu_allow_sudo_' pathlist = glob.glob(prefix+'*') userlist = [s[len(prefix):] for s in pathlist] return userlist