无法使用 Ansible 复制模块复制目录

Cannot copy a directory with Ansible copy module

我一直在尝试将目录(在 Linux 中)复制到远程 Windows 节点。我可以毫无问题地复制单个文件。但是当我试图复制目录时出现以下错误。

环境:Windows 7

命令:ansible --verbose Windows -m copy -a "src=~/Releases dest=C:\Ansible"

错误:

10.8.0.4 | FAILED => Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ansible/runner/__init__.py", line 561, in _executor
    exec_rc = self._executor_internal(host, new_stdin)
  File "/usr/lib/python2.7/dist-packages/ansible/runner/__init__.py", line 666, in _executor_internal
    return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
  File "/usr/lib/python2.7/dist-packages/ansible/runner/__init__.py", line 884, in _executor_internal_inner
    result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
  File "/usr/lib/python2.7/dist-packages/ansible/runner/action_plugins/copy.py", line 252, in run
    module_return = self.runner._execute_module(conn, tmp_path, 'copy', module_args_tmp, inject=inject, complex_args=complex_args, delete_remote_tmp=delete_remote_tmp)
  File "/usr/lib/python2.7/dist-packages/ansible/runner/__init__.py", line 483, in _execute_module
    argsfile = self._transfer_str(conn, tmp, 'arguments', utils.jsonify(utils.parse_kv(args)))
  File "/usr/lib/python2.7/dist-packages/ansible/utils/__init__.py", line 690, in parse_kv
    vargs = split_args(args)
  File "/usr/lib/python2.7/dist-packages/ansible/module_utils/splitter.py", line 182, in split_args
    raise Exception("error while splitting arguments, either an unbalanced jinja2 block or quotes")
Exception: error while splitting arguments, either an unbalanced jinja2 block or quotes

Ansible 目前有相当 limited set of modules for Windows, and I don't believe that the copy module is supported for Windows systems. Windows versions of the copy, file, and template modules were recently accepted into the ansible-modules-core project on github. It looks like they depend on a separate pull request into ansible 本身,而且它显然计划在 ansible 1.9 中可用。这些模块在可用时将被命名为 win_copy、win_file 和 win_template。

是的,完全同意 Bruce 的观点。

我发现这个非常有用的模块是副本。ps1

https://gist.github.com/tkinz27/fd92ba9af0e0309614ee

然后事情就开始了:-)

重要提示:您必须将 Windows (7) Powershell 升级到版本 4.0

是的,很高兴看到新的 windows Ansible 功能主义者。