|
|
@ -42,10 +42,11 @@ except ImportError:
|
|
|
|
|
|
|
|
|
|
|
|
from ansible import constants as C
|
|
|
|
from ansible import constants as C
|
|
|
|
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
|
|
|
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
|
|
|
from ansible.plugins.connections import ConnectionBase
|
|
|
|
from ansible.plugins.connections import ConnectionBase, ensure_connect
|
|
|
|
from ansible.plugins import shell_loader
|
|
|
|
from ansible.plugins import shell_loader
|
|
|
|
from ansible.utils.path import makedirs_safe
|
|
|
|
from ansible.utils.path import makedirs_safe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Connection(ConnectionBase):
|
|
|
|
class Connection(ConnectionBase):
|
|
|
|
'''WinRM connections over HTTP/HTTPS.'''
|
|
|
|
'''WinRM connections over HTTP/HTTPS.'''
|
|
|
|
|
|
|
|
|
|
|
@ -151,6 +152,7 @@ class Connection(ConnectionBase):
|
|
|
|
self.protocol = self._winrm_connect()
|
|
|
|
self.protocol = self._winrm_connect()
|
|
|
|
return self
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ensure_connect
|
|
|
|
def exec_command(self, cmd, tmp_path, executable='/bin/sh', in_data=None):
|
|
|
|
def exec_command(self, cmd, tmp_path, executable='/bin/sh', in_data=None):
|
|
|
|
|
|
|
|
|
|
|
|
cmd = cmd.encode('utf-8')
|
|
|
|
cmd = cmd.encode('utf-8')
|
|
|
@ -172,6 +174,7 @@ class Connection(ConnectionBase):
|
|
|
|
raise AnsibleError("failed to exec cmd %s" % cmd)
|
|
|
|
raise AnsibleError("failed to exec cmd %s" % cmd)
|
|
|
|
return (result.status_code, '', result.std_out.encode('utf-8'), result.std_err.encode('utf-8'))
|
|
|
|
return (result.status_code, '', result.std_out.encode('utf-8'), result.std_err.encode('utf-8'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ensure_connect
|
|
|
|
def put_file(self, in_path, out_path):
|
|
|
|
def put_file(self, in_path, out_path):
|
|
|
|
self._display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._connection_info.remote_addr)
|
|
|
|
self._display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._connection_info.remote_addr)
|
|
|
|
if not os.path.exists(in_path):
|
|
|
|
if not os.path.exists(in_path):
|
|
|
@ -210,6 +213,7 @@ class Connection(ConnectionBase):
|
|
|
|
traceback.print_exc()
|
|
|
|
traceback.print_exc()
|
|
|
|
raise AnsibleError("failed to transfer file to %s" % out_path)
|
|
|
|
raise AnsibleError("failed to transfer file to %s" % out_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ensure_connect
|
|
|
|
def fetch_file(self, in_path, out_path):
|
|
|
|
def fetch_file(self, in_path, out_path):
|
|
|
|
out_path = out_path.replace('\\', '/')
|
|
|
|
out_path = out_path.replace('\\', '/')
|
|
|
|
self._display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._connection_info.remote_addr)
|
|
|
|
self._display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._connection_info.remote_addr)
|
|
|
|