我试图使用Ansping ping Windows主机,但无法ping。
得到以下错误:
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "#< CLIXML\r\n<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S S=\"Error\">invalid payload_x000D__x000A_</S><S S=\"Error\">At line:4 char:44_x000D__x000A_</S><S S=\"Error\">+ If (-not $split_parts.Length -eq 2) { throw <<<< \"invalid payload\" }_x000D__x000A_</S><S S=\"Error\"> + CategoryInfo : OperationStopped: (invalid payload:String) [], R _x000D__x000A_</S><S S=\"Error\"> untimeException_x000D__x000A_</S><S S=\"Error\"> + FullyQualifiedErrorId : invalid payload_x000D__x000A_</S><S S=\"Error\"> _x000D__x000A_</S></Objs>",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
库存文件:
[winnode]
localhost
group_vars:
ansible_port: 5985
ansible_connection: winrm
ansible_user: XXXXX
ansible_password: XXXXXX
ansible_winrm_scheme: http
ansible_winrm_kerberos_delegation: true
Playbook.yml:
- hosts: winnode
gather_facts: no
tasks:
- name: "ping host"
win_ping:
register: download_result
- name: "display result"
debug:
var: download_result
通过使用win_rm
,我试图在Windows中访问剧本,但出现问题。
telnet适用于5985后,能够连接telnet,但是通过使用ansible无法连接并获得ping命令的结果。
答案 0 :(得分:0)
就我而言,这是由于使用的旧版PowerShell与Ansible不兼容。如果您使用的是Windows Server 2008,这很常见。
您将要按照以下说明进行升级:
https://www.rootusers.com/install-powershell-5-windows-server-2008-r2/
作为先决条件,您还需要安装.NET Framework 4.5.2或更高版本,该链接也包含在上面的链接中。