diff options
author | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-04-25 09:33:43 -0400 |
---|---|---|
committer | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-04-25 10:56:56 -0400 |
commit | dea21123218a3ac602f9a859ffddae8e72e4194d (patch) | |
tree | f24daa60dd85b29a6867969f5d0ce98b3cc801fd /ms | |
parent | 79895ed99627931ab6c934dab074e36c3e9e06a4 (diff) |
Finalize ansible usage
Change-Id: Iaca6bb573e31607eaa9a3a603e1e4beae60c817c
Issue-ID: CCSDK-1215
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms')
-rw-r--r-- | ms/command-executor/src/main/python/command_executor_handler.py | 15 |
1 files changed, 12 insertions, 3 deletions
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) |