* moved the logging statement
moved the logging statement before the actual action
* added status code check
In the existing implementation when the ssh command fails the command
result is silently discarded. It hides the fact that the disconnection
did not go as expected. Effectively the intended action was not
successful, but the play continues.
* Revert "added status code check"
This reverts commit fe2eb2ae4a
.
* added command status code check
In the existing implementation the command is checked for the success.
As a result failed execution is silently discarded. The change tests for
return code and fails if it did not work.
This commit is contained in:
parent
c13b1a718a
commit
c3ffc49914
1 changed files with 4 additions and 1 deletions
|
@ -894,9 +894,12 @@ class Connection(ConnectionBase):
|
|||
cmd = map(to_bytes, self._build_command(self._play_context.ssh_executable, '-O', 'stop', self.host))
|
||||
controlpersist, controlpath = self._persistence_controls(cmd)
|
||||
if controlpersist:
|
||||
display.vvv(u'sending stop: %s' % cmd)
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
display.vvv(u'sending stop: %s' % cmd)
|
||||
status_code = p.wait()
|
||||
if status_code != 0:
|
||||
raise AnsibleError("Cannot reset connection:\n%s" % stderr)
|
||||
|
||||
self.close()
|
||||
|
||||
|
|
Loading…
Reference in a new issue