Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker_container: UnicodeDecodeError on probe to set docker ENV variable with non ASCII chars #640

Closed
EGD opened this issue Jul 9, 2020 · 5 comments · Fixed by #642
Closed
Labels
bug This issue/PR relates to a bug cloud docker has_pr module module plugins plugin (any type) python3 traceback

Comments

@EGD
Copy link

EGD commented Jul 9, 2020

SUMMARY

If i put any Cyrillic chars in docker ENV then running ansible-playbook myapp.yml fails with Python error:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 17: ordinal not in range(128)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

docker_container

ANSIBLE VERSION
ansible 2.9.6
ansible python module location = /usr/lib/python3.6/site-packages/ansible
python version = 3.6.10 (default, Jan 16 2020, 09:12:04) [GCC]
CONFIGURATION

OS / ENVIRONMENT
  • CentOS Linux 7
  • Python 2.7.5
  • Docker version 1.13.1, build 64e9980/1.13.1
STEPS TO REPRODUCE
  1. create docker container with ansible
---
 - hosts:
    - virtualbox
  tasks:
    - name: pull image and restart container
      docker_container:
         image: busybox
        name: test_non_ascii
        env:
          MY_ENV_TO: "Абвг «Д»"
        command: "echo $MY_ENV_TO"
  1. run this playbook again
EXPECTED RESULTS

no error

ACTUAL RESULTS
MODULE FAILURE
File \"/tmp/ansible_docker_container_payload_LJPmWa/ansible_docker_container_payload.zip/ansible/modules/cloud/docker/docker_container.py\", line 2174, in has_different_configuration\r\nUnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 17: ordinal not in range(128)\r\n"
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1594371809.4944637-14716-155893099858081/AnsiballZ_docker_container.py", line 102, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1594371809.4944637-14716-155893099858081/AnsiballZ_docker_container.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1594371809.4944637-14716-155893099858081/AnsiballZ_docker_container.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.cloud.docker.docker_container', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python2.7/runpy.py", line 176, in run_module
    fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/ansible_docker_container_payload_etxiiI/ansible_docker_container_payload.zip/ansible/modules/cloud/docker/docker_container.py", line 3369, in <module>
  File "/tmp/ansible_docker_container_payload_etxiiI/ansible_docker_container_payload.zip/ansible/modules/cloud/docker/docker_container.py", line 3360, in main
  File "/tmp/ansible_docker_container_payload_etxiiI/ansible_docker_container_payload.zip/ansible/modules/cloud/docker/docker_container.py", line 2568, in __init__
  File "/tmp/ansible_docker_container_payload_etxiiI/ansible_docker_container_payload.zip/ansible/modules/cloud/docker/docker_container.py", line 2639, in present
  File "/tmp/ansible_docker_container_payload_etxiiI/ansible_docker_container_payload.zip/ansible/modules/cloud/docker/docker_container.py", line 2174, in has_different_configuration
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 10: ordinal not in range(128)```
@felixfontein felixfontein changed the title UnicodeDecodeError on probe to set docker ENV variable with non ASCII chars docker_container: UnicodeDecodeError on probe to set docker ENV variable with non ASCII chars Jul 11, 2020
@felixfontein
Copy link
Collaborator

This seems to be a Python 2 problem; with Python 3 I cannot reproduce it. I'll look into it more closely the next days...

@felixfontein
Copy link
Collaborator

resolved_by_pr #642

@EGD
Copy link
Author

EGD commented Jul 14, 2020

openSUSE request: https://build.opensuse.org/request/show/820899

@felixfontein
Copy link
Collaborator

I've created a backport to stable-2.9 at ansible/ansible#70646.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jul 29, 2020
v2.9.11
=======

Minor Changes
-------------
- The ``items2dict`` filter can now create a dict whose values are the original elements of the input list, and whose keys are the value of some key in each dict. When the resulting dict is stored, this allows for O(1) lookup of a particular key without having to scan the entire list each time.
- k8s - update openshift requirements in documentation
- pipe lookup - update docs for Popen with shell=True usages (ansible/ansible#70159).

Bugfixes
--------
- Allow TypeErrors on Undefined variables in filters to be handled or deferred when processing for loops.
- Fix ``delegate_facts: true`` when ``ansible_python_interpreter`` is not set. (ansible/ansible#70168)
- Support check mode in NXOS BGP modules (ansible/ansible#57360).
- TaskExecutor - Handle unexpected errors as failed while post validating loops (ansible/ansible#70050).
- The `ansible_become` value was not being treated as a boolean value when set in an INI format inventory file (fixes bug ansible/ansible#70476).
- To fix ios_l2_interfaces facts parsing issue (ansible-collections/cisco.ios#59)
- To fix ios_user and ios_command test case failure fix (ansible-collections/cisco.ios#82)
- Vault - Allow single vault encrypted values to be used directly as module parameters. (ansible/ansible#68275)
- add constraints file for ``anisble_runner`` test since an update to ``psutil`` is now causing test failures
- ansible-galaxy - Instead of assuming the first defined server is galaxy, filter based on the servers that support the v1 API, and return the first of those (ansible/ansible#65440)
- ansible-test no longer tracebacks during change analysis due to processing an empty python file
- ansible-test now correctly recognizes imports in collections when using the ``--changed`` option.
- ansible-test now ignores empty ``*.py`` files when analyzing module_utils imports for change detection
- assemble - fix decrypt argument in the module (ansible/ansible#65450).
- docker_container - various error fixes in string handling for Python 2 to avoid crashes when non-ASCII characters are used in strings (ansible-collections/community.general#640).
- eos_eapi - enable eapi by default
- group_by now should correctly refect changed status.
- json callback - Fix host result to task references in the resultant JSON output for non-lockstep strategy plugins such as free (ansible/ansible#65931)
- nmcli - Add compatibility for new networkmanager library (ansible/ansible#65726).
- puppet - fix command line construction for check mode and ``manifest:`` (ansible/ansible#60576).
- selective callback - mark task failed correctly (ansible/ansible#63767).
- windows async - use full path when calling PowerShell to reduce reliance on environment vars being correct - ansible/ansible#70655
- winrm - preserve winrm forensic data on put_file failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug cloud docker has_pr module module plugins plugin (any type) python3 traceback
Projects
None yet
3 participants