Add sudo option to script hooks
This commit is contained in:
parent
61f7f33c92
commit
c86a14477c
|
@ -227,6 +227,7 @@ def run_hook_script(config, targets, args):
|
||||||
source = args.get("source", None)
|
source = args.get("source", None)
|
||||||
path = args.get("path", None)
|
path = args.get("path", None)
|
||||||
arguments = args.get("arguments", [])
|
arguments = args.get("arguments", [])
|
||||||
|
use_sudo = args.get("use_sudo", False)
|
||||||
|
|
||||||
logger.info(f"Running script on node {node_name}")
|
logger.info(f"Running script on node {node_name}")
|
||||||
|
|
||||||
|
@ -262,6 +263,9 @@ def run_hook_script(config, targets, args):
|
||||||
else:
|
else:
|
||||||
remote_command = remote_path
|
remote_command = remote_path
|
||||||
|
|
||||||
|
if use_sudo:
|
||||||
|
remote_command = f"sudo {remote_command}"
|
||||||
|
|
||||||
stdin, stdout, stderr = c.exec_command(remote_command)
|
stdin, stdout, stderr = c.exec_command(remote_command)
|
||||||
logger.debug(stdout.readlines())
|
logger.debug(stdout.readlines())
|
||||||
logger.debug(stderr.readlines())
|
logger.debug(stderr.readlines())
|
||||||
|
|
Loading…
Reference in New Issue