|
|
|
@ -42,6 +42,7 @@ from ansible import constants as C
|
|
|
|
|
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
|
|
|
|
from ansible.plugins.connection import ConnectionBase
|
|
|
|
|
from ansible.utils.path import makedirs_safe
|
|
|
|
|
from ansible.utils.unicode import to_bytes
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from __main__ import display
|
|
|
|
@ -270,7 +271,7 @@ class Connection(ConnectionBase):
|
|
|
|
|
|
|
|
|
|
display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._play_context.remote_addr)
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(in_path):
|
|
|
|
|
if not os.path.exists(to_bytes(in_path, errors='strict')):
|
|
|
|
|
raise AnsibleFileNotFound("file or module does not exist: %s" % in_path)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
@ -279,7 +280,7 @@ class Connection(ConnectionBase):
|
|
|
|
|
raise AnsibleError("failed to open a SFTP connection (%s)" % e)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
self.sftp.put(in_path, out_path)
|
|
|
|
|
self.sftp.put(to_bytes(in_path, errors='strict'), to_bytes(out_path, errors='strict'))
|
|
|
|
|
except IOError:
|
|
|
|
|
raise AnsibleError("failed to transfer file to %s" % out_path)
|
|
|
|
|
|
|
|
|
@ -305,7 +306,7 @@ class Connection(ConnectionBase):
|
|
|
|
|
raise AnsibleError("failed to open a SFTP connection (%s)", e)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
self.sftp.get(in_path, out_path)
|
|
|
|
|
self.sftp.get(to_bytes(in_path, errors='strict'), to_bytes(out_path, errors='strict'))
|
|
|
|
|
except IOError:
|
|
|
|
|
raise AnsibleError("failed to transfer file from %s" % in_path)
|
|
|
|
|
|
|
|
|
|