0
votes

I am trying to ping windows host from using ansible, but unable to ping.

getting below errors:

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 &lt;&lt;&lt;&lt;  \"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
}

Inventory file:

[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

By using win_rm I am trying to access playbook in windows, but I am getting issues.

telnet is working for post 5985, able to connect telnet, but by using ansible unable to connect and get the result of ping command.

1
Are you trying on localhost? Is ansible server itself windows?Smily

1 Answers

0
votes

In my case, this is due to being on an older version of PowerShell which is incompatible with Ansible. This is common if you are using Windows Server 2008.

Image of powershell version

You will want to follow these instructions for upgrading:

https://www.rootusers.com/install-powershell-5-windows-server-2008-r2/

As a prerequisite, you will also need to install .NET Framework 4.5.2 or later, which is also included in the post in the above link.