Add sudo option to script hooks

This commit is contained in:
Joshua Boniface 2022-07-06 19:42:25 +00:00
parent 61f7f33c92
commit c86a14477c
1 changed files with 4 additions and 0 deletions

View File

@ -227,6 +227,7 @@ def run_hook_script(config, targets, args):
source = args.get("source", None)
path = args.get("path", None)
arguments = args.get("arguments", [])
use_sudo = args.get("use_sudo", False)
logger.info(f"Running script on node {node_name}")
@ -262,6 +263,9 @@ def run_hook_script(config, targets, args):
else:
remote_command = remote_path
if use_sudo:
remote_command = f"sudo {remote_command}"
stdin, stdout, stderr = c.exec_command(remote_command)
logger.debug(stdout.readlines())
logger.debug(stderr.readlines())