Getting error as invalid_payload using win_copy ansible module

Hi,

I am trying to copy a zip file on windows machine.For this I am using win_copy module.The issue is that for some windows server it works fine but for some it is failing to copy zip files.

This is the ansible tasks:-

- name: Copy telegraf zip
  win_copy:
    src: /git/telegraf/{{ telegraf_zip_name }}
    dest: c:\temp\
  vars:
    ansible_user: NTNET\win_user  # Replace with your domain and username
    ansible_password: ""  # Replace with your password
    ansible_connection: winrm
    ansible_winrm_transport: ntlm
    ansible_winrm_server_cert_validation: ignore
  tags: packages

I am executing the playbook via AWX job template.

This is the error message which I am getting:-

fatal: [IEO2VMCTXWEB01]: FAILED! => {"changed": false, "checksum": "3af2e98cd5f5d851b96a1fe98af9e06f4cb79170", "dest": "c:\\temp\\telegraf-1.21.2_windows_amd64.zip", "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", "operation": "file_copy", "original_basename": "telegraf-1.21.2_windows_amd64.zip", "rc": 1, "size": 34408954, "src": "/git/telegraf/telegraf-1.21.2…

Ansible_Details:-

ansible 2.9.18
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

Request you to please help me on this as I have recently started using ansible.And this is something very imp to fix asap.

Please let me know if more details are reqd from my end.

The OS or PowerShell of the target host may be old.

Please check if there is any difference in OS or PowerShell version between the host that works well and the host where the error occurs.

1 Like

Hi @kurokobo ,

First of all thanks for the quick response.Appreciate it.

Yes I saw the difference between the powershell version’s for the working host and not working hosts:-

1.) Working host powershell version:-
Major Minor Build Revision
5 1 14409 1029

2.) Not working powershell version:-
Major Minor Build Revision
2 0 -1 -1

I have 2 questions:-

1.) Does win_copy has any relation with powershell ?
2.) Do I need to upgrade or do something with the powershel with the version’s which is working.

Thanks for your rapid update!

Yes, Ansible uses PowerShell to manage Windows-based target host.
Since you seem to be using Ansible 2.9, so first of all please refer to Ansible 2.9 User Guide:

  • Ansible requires PowerShell 3.0 or newer and at least .NET 4.0 to be installed on the Windows host.

Setting up a Windows Host — Ansible Documentation

Maybe upgrading PowerShell and .NET Framework are required.
The user guide above also provides basic steps to make your Windows host meet requirements, so please give it a try.

2 Likes

Hi @kurokobo ,

Thanks for providing me this details.

Will check,test and let you know.

Thanks Alot for your quick help :smiley:

Not to put too fine a point on this, but 2.9 seems to be EOL. Maybe you should try with a more recent version.

3 Likes

Hi @kurokobo @mariolenz ,

Can you guys please help me on this issue

@husnain_taja this appears to be an ansible issue rather than an awx issue. Would you mind adjusting the labels accordingly? That will help ensure the correct team sees this.

Thank you for your time!

@husnain_taja this appears to be an ansible issue rather than an awx issue. Would you mind adjusting the labels accordingly? That will help ensure the correct team sees this.

It’s ultimately a neither issue, OP is targeting a host that has PowerShell 2.0 which has never been supported by Ansible. The latest version of Ansible only supports PowerShell 5.1 while some older do work with 3.0, and 4.0. They’ll need to update their host to ensure they are running with a compatible PowerShell version.

1 Like