# UnicodeDecodeError with Ansible 1.9.4 and German Letter

**URL:** <https://forum.ansible.com/t/unicodedecodeerror-with-ansible-1-9-4-and-german-letter/19513>\
**Category:** Ansible Project\
**Tags:** windows, ubuntu\
**Created:** [October 15, 2015, 12:55pm UTC](https://forum.ansible.com/t/unicodedecodeerror-with-ansible-1-9-4-and-german-letter/19513 "2015-10-15T12:55:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thoralf\_Liersch](https://avatars.discourse-cdn.com/v4/letter/t/b19c9b/32.png) [@Thoralf\_Liersch](https://forum.ansible.com/u/Thoralf_Liersch)\
**Post date:** [October 15, 2015, 12:55pm UTC](https://forum.ansible.com/t/unicodedecodeerror-with-ansible-1-9-4-and-german-letter/19513/1 "2015-10-15T12:55:37Z")

</div>

Hi,

i have a problem to provisioning a windows client.  
The Windows Client is a Windows 10 Prof, the management machine is a mac osx or a ubuntu. I have both the same problem.

the command: ansible berater -m raw -a “ipconfig” -i hosts -vvvvv  
works fine and gives me the output what i want  
the output:

`

ansible berater -m raw -a “ipconfig” -i hosts -vvvvv  
\<10.8.32.91\> ESTABLISH WINRM CONNECTION FOR USER: Admin on PORT 5986 TO 10.8.32.91  
\<10.8.32.91\> WINRM CONNECT: transport=plaintext endpoint=[https://10.8.32.91:5986/wsman](https://10.8.32.91:5986/wsman)  
\<10.8.32.91\> EXEC ipconfig  
\<10.8.32.91\> WINRM EXEC ‘ipconfig’   
\<10.8.32.91\> WINRM RESULT \<Response code 0, out " Windows-IP-Konfigu", err “”\>  
\<10.8.32.91\> WINRM STDOUT Windows-IP-Konfiguration Drahtlos-LAN-Adapter Drahtlosnetzwerkverbindung: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: Drahtlos-LAN-Adapter LAN-Verbindung\* 2: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: Drahtlos-LAN-Adapter LAN-Verbindung\* 4: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: Ethernet-Adapter LAN-Verbindung: Verbindungsspezifisches DNS-Suffix: fc.local Verbindungslokale IPv6-Adresse . : fe80::c566:aab4:dee0:1829%9 IPv4-Adresse . . . . . . . . . . : 10.8.32.91 Subnetzmaske . . . . . . . . . . : 255.255.255.0 Standardgateway . . . . . . . . . : 10.8.32.1 Ethernet-Adapter Bluetooth-Netzwerkverbindung 2: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: Tunneladapter isatap.fc.local: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: fc.local Tunneladapter Teredo Tunneling Pseudo-Interface: Verbindungsspezifisches DNS-Suffix: IPv6-Adresse. . . . . . . . . . . : 2001:0:9d38:6abd:cdc:e5:abd1:a435 Verbindungslokale IPv6-Adresse . : fe80::cdc:e5:abd1:a435%6 Standardgateway . . . . . . . . . : ::  
\<10.8.32.91\> WINRM STDERR  
10.8.32.91 | success | rc=0 \>\>

Windows-IP-Konfiguration

Drahtlos-LAN-Adapter Drahtlosnetzwerkverbindung:

Medienstatus. . . . . . . . . . . : Medium getrennt  
Verbindungsspezifisches DNS-Suffix:

Drahtlos-LAN-Adapter LAN-Verbindung\* 2:

Medienstatus. . . . . . . . . . . : Medium getrennt  
Verbindungsspezifisches DNS-Suffix:

Drahtlos-LAN-Adapter LAN-Verbindung\* 4:

Medienstatus. . . . . . . . . . . : Medium getrennt  
Verbindungsspezifisches DNS-Suffix:

Ethernet-Adapter LAN-Verbindung:

Verbindungsspezifisches DNS-Suffix: fc.local  
Verbindungslokale IPv6-Adresse . : fe80::c566:aab4:dee0:1829%9  
IPv4-Adresse . . . . . . . . . . : 10.8.32.91  
Subnetzmaske . . . . . . . . . . : 255.255.255.0  
Standardgateway . . . . . . . . . : 10.8.32.1

Ethernet-Adapter Bluetooth-Netzwerkverbindung 2:

Medienstatus. . . . . . . . . . . : Medium getrennt  
Verbindungsspezifisches DNS-Suffix:

Tunneladapter isatap.fc.local:

Medienstatus. . . . . . . . . . . : Medium getrennt  
Verbindungsspezifisches DNS-Suffix: fc.local

Tunneladapter Teredo Tunneling Pseudo-Interface:

Verbindungsspezifisches DNS-Suffix:  
IPv6-Adresse. . . . . . . . . . . : 2001:0:9d38:6abd:cdc:e5:abd1:a435  
Verbindungslokale IPv6-Adresse . : fe80::cdc:e5:abd1:a435%6  
Standardgateway . . . . . . . . . : ::

`

the command: ansible berater -m raw -a “ipconfig /all” -i hosts -vvvvv

works not. the output included german letters and produce the error: UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0x84 in position 90: ordinal not in range(128)  
the output:

`

ansible berater -m raw -a “ipconfig /all” -i hosts -vvvvv  
\<10.8.32.91\> ESTABLISH WINRM CONNECTION FOR USER: Admin on PORT 5986 TO 10.8.32.91  
\<10.8.32.91\> WINRM CONNECT: transport=plaintext endpoint=[https://10.8.32.91:5986/wsman](https://10.8.32.91:5986/wsman)  
\<10.8.32.91\> EXEC ipconfig /all  
\<10.8.32.91\> WINRM EXEC ‘ipconfig’ [‘/all’]  
\<10.8.32.91\> WINRM RESULT \<Response code 0, out " Windows-IP-Konfigu", err “”\>  
\<10.8.32.91\> WINRM STDOUT Windows-IP-Konfiguration Hostname . . . . . . . . . . . . : FFG-TCTA-031 Prim�res DNS-Suffix . . . . . . . : Knotentyp . . . . . . . . . . . . : Hybrid IP-Routing aktiviert . . . . . . : Nein WINS-Proxy aktiviert . . . . . . : Nein DNS-Suffixsuchliste . . . . . . . : fc.local Drahtlos-LAN-Adapter Drahtlosnetzwerkverbindung: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: Beschreibung. . . . . . . . . . . : Intel(R) Wireless-N 7260 Physische Adresse . . . . . . . . : 7C-5C-F8-19-B4-CD DHCP aktiviert. . . . . . . . . . : Ja Autokonfiguration aktiviert . . . : Ja Drahtlos-LAN-Adapter LAN-Verbindung\* 2: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: Beschreibung. . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter Physische Adresse . . . . . . . . : 7C-5C-F8-19-B4-CE DHCP aktiviert. . . . . . . . . . : Ja Autokonfiguration aktiviert . . . : Ja Drahtlos-LAN-Adapter LAN-Verbindung\* 4: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: Beschreibung. . . . . . . . . . . : Microsoft Hosted Network Virtual Adapter Physische Adresse . . . . . . . . : 7E-5C-F8-19-B4-CD DHCP aktiviert. . . . . . . . . . : Ja Autokonfiguration aktiviert . . . : Ja Ethernet-Adapter LAN-Verbindung: Verbindungsspezifisches DNS-Suffix: fc.local Beschreibung. . . . . . . . . . . : Intel(R) Ethernet Connection I218-V Physische Adresse . . . . . . . . : B8-AE-ED-72-80-22 DHCP aktiviert. . . . . . . . . . : Ja Autokonfiguration aktiviert . . . : Ja Verbindungslokale IPv6-Adresse . : fe80::c566:aab4:dee0:1829%9(Bevorzugt) IPv4-Adresse . . . . . . . . . . : 10.8.32.91(Bevorzugt) Subnetzmaske . . . . . . . . . . : 255.255.255.0 Lease erhalten. . . . . . . . . . : Donnerstag, 15. Oktober 2015 11:05:54 Lease l�uft ab. . . . . . . . . . : Donnerstag, 22. Oktober 2015 11:05:51 Standardgateway . . . . . . . . . : 10.8.32.1 DHCP-Server . . . . . . . . . . . : 10.8.32.1 DHCPv6-IAID . . . . . . . . . . . : 247480277 DHCPv6-Client-DUID. . . . . . . . : 00-01-00-01-1D-94-13-C5-B8-AE-ED-72-80-22 DNS-Server . . . . . . . . . . . : 10.8.32.1 NetBIOS �ber TCP/IP . . . . . . . : Aktiviert Ethernet-Adapter Bluetooth-Netzwerkverbindung 2: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: Beschreibung. . . . . . . . . . . : Bluetooth Device (Personal Area Network) Physische Adresse . . . . . . . . : 7C-5C-F8-19-B4-D1 DHCP aktiviert. . . . . . . . . . : Ja Autokonfiguration aktiviert . . . : Ja Tunneladapter isatap.fc.local: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: fc.local Beschreibung. . . . . . . . . . . : Microsoft ISATAP Adapter Physische Adresse . . . . . . . . : 00-00-00-00-00-00-00-E0 DHCP aktiviert. . . . . . . . . . : Nein Autokonfiguration aktiviert . . . : Ja Tunneladapter Teredo Tunneling Pseudo-Interface: Verbindungsspezifisches DNS-Suffix: Beschreibung. . . . . . . . . . . : Teredo Tunneling Pseudo-Interface Physische Adresse . . . . . . . . : 00-00-00-00-00-00-00-E0 DHCP aktiviert. . . . . . . . . . : Nein Autokonfiguration aktiviert . . . : Ja IPv6-Adresse. . . . . . . . . . . : 2001:0:9d38:6abd:cdc:e5:abd1:a435(Bevorzugt) Verbindungslokale IPv6-Adresse . : fe80::cdc:e5:abd1:a435%6(Bevorzugt) Standardgateway . . . . . . . . . : :: DHCPv6-IAID . . . . . . . . . . . : 486539264 DHCPv6-Client-DUID. . . . . . . . : 00-01-00-01-1D-94-13-C5-B8-AE-ED-72-80-22 NetBIOS �ber TCP/IP . . . . . . . : Deaktiviert  
\<10.8.32.91\> WINRM STDERR  
10.8.32.91 | FAILED =\> Traceback (most recent call last):  
File “/Library/Python/2.7/site-packages/ansible/runner/ **init**.py”, line 586, in \_executor  
exec\_rc = self.\_executor\_internal(host, new\_stdin)  
File “/Library/Python/2.7/site-packages/ansible/runner/ **init**.py”, line 789, in \_executor\_internal  
return self.\_executor\_internal\_inner(host, self.module\_name, self.module\_args, inject, port, complex\_args=complex\_args)  
File “/Library/Python/2.7/site-packages/ansible/runner/ **init**.py”, line 1036, in \_executor\_internal\_inner  
result = handler.run(conn, tmp, module\_name, module\_args, inject, complex\_args)  
File “/Library/Python/2.7/site-packages/ansible/runner/action\_plugins/raw.py”, line 47, in run  
become=self.runner.become)  
File “/Library/Python/2.7/site-packages/ansible/runner/ **init**.py”, line 1174, in \_low\_level\_exec\_command  
in\_data=in\_data)  
File “/Library/Python/2.7/site-packages/ansible/runner/connection\_plugins/winrm.py”, line 165, in exec\_command  
return (result.status\_code, ‘’, result.std\_out.encode(‘utf-8’), result.std\_err.encode(‘utf-8’))  
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0x84 in position 90: ordinal not in range(128)

`

can anyone help?  
thanks thoralf

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [October 15, 2015, 9:08pm UTC](https://forum.ansible.com/t/unicodedecodeerror-with-ansible-1-9-4-and-german-letter/19513/2 "2015-10-15T21:08:55Z")

</div>

I don't do anything with Windows unfortunately, but that error  
probably means that either result.std\_out or result.std\_err are  
already encoded to bytes. You could see if doing this fixes the  
issue:

from ansible.utils.unicode import to\_bytes  
return (result.status\_code, '', to\_bytes(result.std\_out),  
to\_bytes(result.std\_err))

If it does be sure to let us know so that we can apply it to the upstream code.

-Toshio

---

<div class="post-metadata">

**Author:** ![Thoralf\_Liersch](https://avatars.discourse-cdn.com/v4/letter/t/b19c9b/32.png) [@Thoralf\_Liersch](https://forum.ansible.com/u/Thoralf_Liersch)\
**Post date:** [October 21, 2015, 8:52am UTC](https://forum.ansible.com/t/unicodedecodeerror-with-ansible-1-9-4-and-german-letter/19513/3 "2015-10-21T08:52:27Z")

</div>

where do I install or run this code because

---

<div class="post-metadata">

**Author:** ![Thoralf\_Liersch](https://avatars.discourse-cdn.com/v4/letter/t/b19c9b/32.png) [@Thoralf\_Liersch](https://forum.ansible.com/u/Thoralf_Liersch)\
**Post date:** [October 21, 2015, 10:13am UTC](https://forum.ansible.com/t/unicodedecodeerror-with-ansible-1-9-4-and-german-letter/19513/4 "2015-10-21T10:13:15Z")

</div>

ok i have changed in ansible/runner/connection\_plugins/winrm.py

# added new line 30

from ansible.utils.unicode import to\_bytes

# deaktivate line 166

# added new line 167

return (result.status\_code, ‘’, to\_bytes(result.std\_out), to\_bytes(result.std\_err))

this works a bit better. the german letters are not displayed.

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [October 21, 2015, 2:47pm UTC](https://forum.ansible.com/t/unicodedecodeerror-with-ansible-1-9-4-and-german-letter/19513/5 "2015-10-21T14:47:35Z")

</div>

> ok i have changed in ansible/runner/connection\_plugins/winrm.py
> 
> # added new line 30
> 
> from ansible.utils.unicode import to\_bytes
> 
> # deaktivate line 166
> 
> # added new line 167
> 
> return (result.status\_code, ‘’, to\_bytes(result.std\_out), to\_bytes(result.std\_err))
> 
> this works a bit better. the german letters are not displayed.

Okay, I’ll apply this for now then so it’s possible for people to continue on.

If someone wants to try getting all characters to properly display they’ll need to know what character encoding Windows uses here and in what circumstances the encoding can be different.

-Toshio
