【问题标题】:How to copy a file from Linux server to Windows server using Ansible playbook如何使用 Ansible playbook 将文件从 Linux 服务器复制到 Windows 服务器
【发布时间】:2022-12-09 13:25:31
【问题描述】:

我想将一些虚拟文件从 Linux 远程服务器复制到 Windows 远程服务器,但我无法成功。我正在使用 AWX,但输出出现错误。

ERROR! 'win_copy' is not s valid attribute for a playbook 

我使用的 Ansible 版本是 2.9.19,AWX 版本是 21.0.0

这是我要运行的剧本:

- name: testing windows files
  hosts: {{ hostname }}
  
  tasks:

- name: Copy a single file
  win_copy:
  src: /path/to/src/test.txt
  dest: user@hostname.domain.name.com:C:\Temp\renamed-test.txt

我尝试使用“复制”属性,但输出是相同的。

注意:我已经安装了 ansible.windows 模块,但没有任何变化。

【问题讨论】:

    标签: linux ansible


    【解决方案1】:

    温多兹很奇怪。通常,Windoze 必须运行 WinRM。

    所以首先要看你是否可以连接:

    - name: testing windoze connections
      hosts: all
      gather_facts: no
      tasks:  
      - name: Ping host
        win_ping:
    

    如果可行,那么您的win_copy 将是:

      - name: Copy file
        win_copy:
          src: '/path/to/src/test.txt'
          dest: 'C:Temp
    enamed-test.txt'
    

    用户名需要在变量ansible_user 中,密码在ansible_password 中。

    【讨论】:

    • 谢谢大侠指点,好像连windows都连不上了。我现在正在搜索“如何将文件从 Linux 共享到 Windows”之类的内容,对此任务有什么建议吗?呵呵
    • 另一个问题,“用户名需要在变量 ansible_user 中,密码需要在 ansible_password 中”是什么意思。我需要在哪里指定这些变量?谢谢!
    猜你喜欢
    • 2010-09-16
    • 1970-01-01
    • 2021-09-28
    • 1970-01-01
    • 1970-01-01
    • 2019-10-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多