Skip to content

Commit

Permalink
add ability to specify path to ansible-playbook binary file in runner
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFieryLynx committed Mar 14, 2024
1 parent bb44893 commit b1dae5c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/cotea/runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import threading

import cotea.utils as cotea_utils
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 = ""

Expand Down

0 comments on commit b1dae5c

Please sign in to comment.