diff --git a/src/cotea/runner.py b/src/cotea/runner.py index 12dc95f..3a543f0 100644 --- a/src/cotea/runner.py +++ b/src/cotea/runner.py @@ -1,4 +1,5 @@ import json +import os import threading import cotea.utils as cotea_utils @@ -35,7 +36,8 @@ class runner: - def __init__(self, pb_path, arg_maker, debug_mod=None, show_progress_bar=False): + def __init__(self, pb_path, arg_maker, debug_mod=None, show_progress_bar=False, + ansible_pb_bin="/usr/local/bin/ansible-playbook"): logging_lvl = logging.INFO if debug_mod: logging_lvl= logging.DEBUG @@ -64,6 +66,11 @@ def __init__(self, pb_path, arg_maker, debug_mod=None, show_progress_bar=False): self.progress_bar = ansible_progress_bar() self.execution_tree = AnsibleExecTree() + if os.path.exists(ansible_pb_bin): + self.ansible_pb_bin = ansible_pb_bin + else: + raise Exception(f"Ansible playbook bin {ansible_pb_bin} not found") + self._set_wrappers() start_ok = self._start_ansible() self.logger.debug("Ansible start ok: %s", start_ok) @@ -133,7 +140,7 @@ def _except_hook(self, args, /): def _start_ansible(self): args = self.arg_maker.args - args.insert(0, "/usr/local/bin/ansible-playbook") + args.insert(0, self.ansible_pb_bin) args.insert(1, self.pb_path) self.pbCLI = PlaybookCLI(args) @@ -363,7 +370,7 @@ def get_all_error_msgs(self): return self.update_conn_wrapper.error_msgs - # returns last error msg that wasn't ignored + # returns last error msg that wasn't ignored def get_error_msg(self): res = ""