From 98b0580be8982810fb0874af1a7b3e1841d6c779 Mon Sep 17 00:00:00 2001 From: Andrew Biryukov Date: Wed, 13 Mar 2024 19:38:33 +0300 Subject: [PATCH] add ability to specify path to ansible-playbook binary file in runner --- src/cotea/runner.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cotea/runner.py b/src/cotea/runner.py index 12dc95f..72c0410 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.isfile(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 = ""