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

Task executor use .format() which have problem with \u2018 characters #19762

Closed
letzdoo-js opened this issue Dec 30, 2016 · 2 comments
Closed
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. python3

Comments

@letzdoo-js
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible/plugins/action/init.py

ANSIBLE VERSION
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION

none

OS / ENVIRONMENT

x86_64 GNU/Linux

SUMMARY

An error coming back from a linux box contains the \u2018 character which seems to have an implementation issue in python 2.x.

see - '{0}'.format(u'Test it\u2018s unicode implementation')
Traceback (most recent call last):
File "", line 1, in
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 7: ordinal not in range(128)

but run fine in python 3.x

STEPS TO REPRODUCE

Message coming back from the linux box, \u2018 is used several times :
fatal: [crlg.be-cloud.be]: FAILED! => {
"failed": true,
"msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: changing ownership of ‘/tmp/ansible-tmp-1483137683.83-3208985635661/’: Operation not permitted\nchown: changing ownership of ‘/tmp/ansible-tmp-1483137683.83-3208985635661/git.py’: Operation not permitted\n). For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"
}

EXPECTED RESULTS

The message should be displayed

ACTUAL RESULTS
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 119, in run
    res = self._execute()
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 490, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/normal.py", line 33, in run
    results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars))
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 618, in _execute_module
    self._fixup_perms2(remote_files, remote_user)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 395, in _fixup_perms2
    ' see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user'.format(res['rc'], res['stderr']))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 29: ordinal not in range(128)

fatal: [crlg.be-cloud.be]: FAILED! => {
    "failed": true, 
    "msg": "Unexpected failure during module execution.", 
    "stdout": ""
}

I fixed the problem using the "xxxx %s xxxx" % (res['rc'], res['stderr']) instead.

@letzdoo-js letzdoo-js changed the title Use format which have problem with \u2018 characters used in some linux messages Task executor use .format() which have problem with \u2018 characters Dec 30, 2016
@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 bug_report needs_triage Needs a first human triage before being processed. python3 labels Dec 30, 2016
@abadger
Copy link
Contributor

abadger commented Jan 4, 2017

I believe this was fixed in this commit to devel: bb5d8fb and cherry-picked to the stable-2.2 branch here: 27be8a1

It should make it into the next 2.2 release. If you'd care to test it out now to make sure you can checkout the stable-2.2 branch and try running from a checkout or you can download the ansible-2.2.1.0-0.2.rc2.tar.gz from here: https://releases.ansible.com/ansible/ to try it out.

I'll close this in a few days unless you report that it's still a problem with one of those. Thanks!

needs_info

@letzdoo-js
Copy link
Author

I patched my install and this works for me.

Thanks !!

@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Jan 18, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. python3
Projects
No open projects
Development

No branches or pull requests

4 participants