diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index e11a6839..86517d74 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -262,6 +262,19 @@ class Connection(ansible.plugins.connection.ConnectionBase): cast(in_path)) ansible_mitogen.helpers.write_path(out_path, output) + def put_data(self, out_path, data): + """ + Implement put_file() by caling the corresponding + ansible_mitogen.helpers function in the target. + + :param str in_path: + Local filesystem path to read. + :param str out_path: + Remote filesystem path to write. + """ + self.call(ansible_mitogen.helpers.write_path, + cast(out_path), cast(data)) + def put_file(self, in_path, out_path): """ Implement put_file() by caling the corresponding @@ -272,5 +285,4 @@ class Connection(ansible.plugins.connection.ConnectionBase): :param str out_path: Remote filesystem path to write. """ - self.call(ansible_mitogen.helpers.write_path, cast(out_path), - ansible_mitogen.helpers.read_path(in_path)) + self.put_data(out_path, ansible_mitogen.helpers.read_path(in_path)) diff --git a/ansible_mitogen/mixins.py b/ansible_mitogen/mixins.py index 48b58cde..db7dac18 100644 --- a/ansible_mitogen/mixins.py +++ b/ansible_mitogen/mixins.py @@ -202,10 +202,10 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase): def _transfer_data(self, remote_path, data): """ - This is used by the base implementation of _execute_module(), it should - never be called. + Used by the base _execute_module(), and in <2.4 also by the template + action module, and probably others. """ - assert False, "_transfer_data() should never be called." + self._connection.put_data(remote_path, data) def _fixup_perms2(self, remote_paths, remote_user=None, execute=True): """