首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Ansible作业模板在远程计算机中运行剧本。连接失败

无法使用Ansible作业模板在远程计算机中运行剧本。连接失败
EN

DevOps用户
提问于 2019-09-26 06:55:53
回答 1查看 363关注 0票数 0

Playbook.yml

代码语言:javascript
复制
---
- name: connectionTest
  hosts: Windows
  tasks:
  - name: "Windows Connect"
    win_command: hostname
    register: wincmd_out

在库存中声明的变量Project/inventories/XXX_Local/

代码语言:javascript
复制
[Windows]
XXVMxxxxxxx

错误信息:

代码语言:javascript
复制
fatal: [XXVMxxxxxxx]: UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket \"/tmp/awx_1636443_S7HHdB/cp/6b18046463\" does not exist\r\ndebug2: resolving \"XXVMxxxxxxx\" port 22\r\nssh: Could not resolve hostname XXVMxxxxxxx: Name or service not known", 
    "unreachable": true
}
EN

回答 1

DevOps用户

回答已采纳

发布于 2019-09-26 09:00:56

看一看您的代码,似乎您试图连接到Windows主机。通常您通过WinRM而不是ssh连接窗口。

这方面的用户指南可以在这里找到:https://docs.ansible.com/ansible/latest/user_指南/窗口_winrm.html

如果无法与Windows主机通信并使用Windows模块,Windows主机必须满足以下要求:

  • Ansible支持的Windows版本通常与Microsoft当前和扩展支持下的版本相匹配。受支持的桌面操作系统包括Windows 7、8.1和10,受支持的服务器操作系统是Windows 2008、2008 R2、2012、R2、2016和2019年。
  • Ansible需要Windows3.0或更高版本,至少需要在PowerShell主机上安装.NET 4.0。
  • 应该创建并激活WinRM侦听器。有关此问题的更多详细信息可在下面找到。

然后,您需要告诉ansible连接wia winrm

代码语言:javascript
复制
...
ansible_connection=winrm
...

查看这里的详细信息:https://www.ansible.com/blog/connecting-to-a-windows-host

票数 1
EN
页面原文内容由DevOps提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://devops.stackexchange.com/questions/9285

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档