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

Error in verbose mode when result contains non ascii code #4

Closed
Patouche opened this issue Feb 1, 2017 · 5 comments
Closed

Error in verbose mode when result contains non ascii code #4

Patouche opened this issue Feb 1, 2017 · 5 comments
Assignees

Comments

@Patouche
Copy link

Patouche commented Feb 1, 2017

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

@octplane octplane self-assigned this Feb 1, 2017
@octplane
Copy link
Owner

octplane commented Feb 1, 2017

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

@octplane
Copy link
Owner

octplane commented Feb 2, 2017

Let me know if this works!

@tnguyen1
Copy link

tnguyen1 commented Mar 3, 2017

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.

@octplane
Copy link
Owner

octplane commented Mar 3, 2017

  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 | }

@tnguyen1
Copy link

tnguyen1 commented Mar 3, 2017

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.

@octplane octplane mentioned this issue Nov 30, 2022
@octplane octplane pinned this issue Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants