From af40d8c2a5a463f37cd17d707e5de961c3503ba8 Mon Sep 17 00:00:00 2001 From: Sofiane Medjkoune Date: Wed, 19 Sep 2018 01:36:51 +0200 Subject: [PATCH] Fix mixed output from ansible and lxd when using the lxd connection plugin (#45246) * Replace fetch and put operations with Popen instead of call to prevent lxd to mess the Ansible output * Remove extra blank line --- lib/ansible/plugins/connection/lxd.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/connection/lxd.py b/lib/ansible/plugins/connection/lxd.py index cdbc80f410..5326cd995c 100644 --- a/lib/ansible/plugins/connection/lxd.py +++ b/lib/ansible/plugins/connection/lxd.py @@ -31,7 +31,7 @@ DOCUMENTATION = """ import os from distutils.spawn import find_executable -from subprocess import call, Popen, PIPE +from subprocess import Popen, PIPE from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound from ansible.module_utils._text import to_bytes, to_text @@ -103,7 +103,8 @@ class Connection(ConnectionBase): local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd] - call(local_cmd) + process = Popen(local_cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) + process.communicate() def fetch_file(self, in_path, out_path): """ fetch a file from lxd to local """ @@ -115,7 +116,8 @@ class Connection(ConnectionBase): local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd] - call(local_cmd) + process = Popen(local_cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) + process.communicate() def close(self): """ close the connection (nothing to do here) """