Manage Windows host : Encoding problem

413 views
Skip to first unread message

Monta Mallek

unread,
Apr 25, 2018, 6:44:27 AM4/25/18
to Ansible Project
Hi,

I'm using Ansible 2.5 to manage a Windows Server 2016 node. I configured WinRM like described in the documentation to remotely connect to the node.

I added a host named W1 to the inventory file and under the folder 'host_vars' I created the file 'W1' that contains the following parameters :

---
ansible_user
: 'Administrateur'
ansible_password
: 'Pass-123'
ansible_connection
: 'winrm'
ansible_winrm_server_cert_validation
: 'ignore'

When I tried to ping to the host using this command 'ansible W1 -m ping', I got this error :

[WARNING]: FATAL ERROR DURING FILE TRANSFER: (u'http', u'Bad HTTP response returned from server. Code 500')

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 29: ordinal not in range(128)
W1 | FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

Any solution for this problem ??

I retried using -vvv to obtain more details :

[WARNING]: FATAL ERROR DURING FILE TRANSFER: (u'http', u'Bad HTTP response returned from server. Code 500')

The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 138, in run
    res = self._execute()
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 558, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/action/normal.py", line 46, in run
    result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
  File "/usr/lib/python2.7/site-packages/ansible/plugins/action/__init__.py", line 795, in _execute_module
    res = self._low_level_execute_command(cmd, sudoable=sudoable, in_data=in_data)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/action/__init__.py", line 902, in _low_level_execute_command
    rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 493, in exec_command
    result = self._winrm_exec(cmd_parts[0], cmd_parts[1:], from_exec=True, stdin_iterator=stdin_iterator)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 435, in _winrm_exec
    raise AnsibleError('winrm send_input failed; \nstdout: %s\nstderr %s' % (response.std_out, stderr))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 29: ordinal not in range(128)

W1 | FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}


Virasat Khan

unread,
Apr 25, 2018, 4:34:57 PM4/25/18
to ansible...@googlegroups.com
Mention the protocol service that you have wnabled on remote. May be credssp or kerberos?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c10d8304-c581-497d-8e19-ae1a7dc6aa48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jordan Borean

unread,
Apr 25, 2018, 6:03:05 PM4/25/18
to Ansible Project
Are you able to share the playbook you are trying to run, the issue you are seeing is that Ansible is trying to throw an exception because it failed to send the module data to the Windows host but because of an encoding issue it isn't showing you the actual error. We just pushed a fix to work through this issue which should let you know more info as to why it failed https://github.com/ansible/ansible/pull/39333. You can test it out by running from the devel branch of Ansible and it will display the stderr received from the host.

Thanks

Jordan

Monta Mallek

unread,
Apr 26, 2018, 4:50:58 AM4/26/18
to Ansible Project
Hi,

I don't know exactly, I just executed this Powershell script on my Windows node :

powershell.exe  -ExecutionPolicy Bypass -File ConfigureRemotingForAnsible.ps1 -CertValidityDays 3650 -Verbose

 The ConfigureRemotingForAnsible.ps1 link is :

Monta Mallek

unread,
Apr 26, 2018, 4:52:49 AM4/26/18
to Ansible Project
Hi,

I'm not using any playbook, I just used this command : 'ansible W1 -m ping'

Jordan Borean

unread,
Apr 26, 2018, 5:17:16 AM4/26/18
to Ansible Project
Hi Monta

Are you able to try out the stable branch, there was a change there to fix that encoding issue, it should narrow down exactly what is going wrong. To test it you run the following;

git clone https://github.com/ansible/ansible.git
cd ansible
source hacking
/env-setup

From there you can run ansible W1 -m ping to see how it goes.

Thanks

Jordan

Monta Mallek

unread,
May 2, 2018, 4:46:45 AM5/2/18
to Ansible Project
It's working now ! Thanks.
Reply all
Reply to author
Forward
0 new messages