octplane / ansible_stdout_compact_logger

Ansible Stdout Compact Logger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in verbose mode when result contains non ascii code

Patouche opened this issue · comments

Hi,

Thanks a lot for your work. I notice a small inconvenience using when I tried to print unicode characters. I got the problem only when I use the -v ansible option.

For example, if you define the following playbook :

---
- name: "Test case for issue unicode"
  hosts: first
  tasks:
    - name: "Error when using -v"
      command: echo -e "\xe2\x98\xba\x0a"

This will produce the output in verbose mode :

[WARNING]: Failure using method (v2_runner_on_ok) in callback plugin (<ansible.plugins.callback.anstomlog.CallbackModule object at 0x7f21b4605c90>): 'ascii'
codec can't encode character u'\u263a' in position 0: ordinal not in range(128)

Once again, thanks for you work.

Patrick

Thanks for the report, I'll look into it quickly.

Let me know if this works!

Hello, thanks for your work and for this fix.

  1. While testing with your test playbook:
---
- name: "Test case for issue unicode"
  hosts: first
  tasks:
   - debug:
       msg: "Ansible est ÉLÉGANT!"
   - name: "Error when using -v"
     command: echo -e "\xe2\x98\xba\x0a"

I got the following message printed:

[2017-03-03 15:01:17.122] debug |   - msg: Ansible est ?L?GANT!

Is this what expected? Did I miss something in my environment?

  1. Besides I still get an error if I use special characters in a tas name, eg:
---
- name: "Test case for issue unicode"
  hosts: first
  tasks:
   - name: "Error with élégant name"
     debug: msg="Hello world!"

Should I open a new issue for that one?

Thanks.

  1. As for me I have:
[2017-03-03 16:09:36.603] debug |   - msg: Ansible est ÉLÉGANT!

Displayed in the console.
My locale is LC_ALL="en_US.utf-8" and my console font knows how to display unicode. But I don't know why it would fail with you. What's your OS/shell/locale combination?

  1. No error in the second case either:
[2017-03-03 16:11:45.717] Error with élégant name | localhost | SUCCESS | 33ms
[2017-03-03 16:11:45.717] Error with élégant name | {
[2017-03-03 16:11:45.717] Error with élégant name |   - msg: Hello world!
[2017-03-03 16:11:45.717] Error with élégant name | }

Hello,

Thanks for the hints. Actually I am using the callback from a Docker container.
It works now and here's what I needed to add to my Dockerfile:

RUN locale-gen en_US.UTF-8  
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8

Thanks again.