From dea21123218a3ac602f9a859ffddae8e72e4194d Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Thu, 25 Apr 2019 09:33:43 -0400 Subject: Finalize ansible usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iaca6bb573e31607eaa9a3a603e1e4beae60c817c Issue-ID: CCSDK-1215 Signed-off-by: Alexis de Talhouët --- .../src/main/python/command_executor_handler.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'ms') diff --git a/ms/command-executor/src/main/python/command_executor_handler.py b/ms/command-executor/src/main/python/command_executor_handler.py index 1fb3e2679..a5951fdb3 100644 --- a/ms/command-executor/src/main/python/command_executor_handler.py +++ b/ms/command-executor/src/main/python/command_executor_handler.py @@ -65,11 +65,20 @@ class CommandExecutorHandler(): return True def execute_command(self, request, results): - # if not self.activate_venv(): - # return False + if not self.activate_venv(): + return False + + cmd = "cd " + self.venv_home + + if "ansible-playbook" in request.command: + cmd = cmd + "; " + request.command + " -e 'ansible_python_interpreter=" + self.venv_home + "/bin/python'" + else: + cmd = cmd + "; " + request.command + + self.logger.info("Command: {}".format(cmd)) try: - results.append(os.popen(request.command).read()) + results.append(os.popen(cmd).read()) except Exception as e: self.logger.info("{} - Failed to execute command. Error: {}".format(self.blueprint_id, e)) results.append(e) -- cgit 1.2.3-korg