如何在清单文件中添加服务器路径 - ansible

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在清单文件中添加服务器路径 - ansible相关的知识,希望对你有一定的参考价值。

我可以访问特定的公共共享点文件夹路径(Windows机器)。从那里我需要把文件放到ansible控制Linux机器。我使用了下面的剧本,我收到了错误。

    - hosts: hosts
      tasks:
      - name: Copy Remote-To-Local (from NAS to ansible)
        synchronize: 
          src=\xxx.dns.namefilesQGlobal\_ApplicationDatahello.txt 
          dest= /tmp/ansible

请注意:我可以访问此文件夹路径\xxx.dns.namefilesQGlobal\_ApplicationData

Inventory file
[hosts]
\xxx.dns.namefilesQGlobal\_ApplicationData
[hosts:vars]
ansible_user=<myID>
ansible_pass=<mypwd>
ansible_port=5986
ansible_connection=winrm
ansible_winrm_transport=credssp
ansible_winrm_server_cert_validation=ignore

错误

  -bash-4.2$ ansible-playbook -i hosts newplaybook.yml


PLAY [hosts] ************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
fatal: [xxx.dns.namefilesQGlobal_ApplicationData]: UNREACHABLE! => {"changed": false, "msg": "credssp: auth method credssp requires a password", "unreachable": true}
答案

我假设您已按照here中的描述为已经设置的Windows支持执行了所有必需的配置。您的库存文件似乎有一个问题是您使用\xxx.dns.namefilesQGlobal\_ApplicationData作为主机名,但您应该使用您要从控制机器连接的机器的可解析名称(类似于xxx.dns.name)。这也在documentation中注明。

以上是关于如何在清单文件中添加服务器路径 - ansible的主要内容,如果未能解决你的问题,请参考以下文章

Ansible 文档译文主机清单文件

自动化运维工具Ansible实战主机清单的管理

Ansible 五(inventory文件 主机清单)

ansible总结

Ansible2:主机清单

Ansible2:主机清单