linuxinstaller/libreticmenu/AnsibleActions.py

27 lines
846 B
Python
Raw Normal View History

2024-09-30 19:32:52 +02:00
import subprocess
import os
import glob
2024-10-06 23:44:04 +02:00
def runAnsiblePlaybook(config, key, branch):
subprocess.run(['ansible-playbook', config['ansiblemenu'][key]['playbook']], check=True, cwd=config['base_path'])
2024-09-30 19:32:52 +02:00
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