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

Template module not happy with UTF-8 chars in filenames #10110

Closed
gilou opened this issue Jan 27, 2015 · 7 comments
Closed

Template module not happy with UTF-8 chars in filenames #10110

gilou opened this issue Jan 27, 2015 · 7 comments
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release

Comments

@gilou
Copy link
Contributor

gilou commented Jan 27, 2015

Issue Type: Bug Report
Ansible Version: 1.8.2, 1.9 (devel a63e4c5)
Environment: Ubuntu 14.10
Summary:
Using template module, if the source file contains UTF-8 characters in its name, it makes it barf.

Steps To Reproduce:
test_utf8.yml

- hosts: superserver
  tasks:
    - name: Test utf
      template: src=héhé.txt dest=/tmp/hihi.txt

Create héhé.txt, run the playbook.

Expected Results: File copied (and rendered).
Actual Results:

fatal: [superserver] => Traceback (most recent call last):
  File "/home/Technique/Code/ansible/lib/ansible/runner/__init__.py", line 590, in _executor
    exec_rc = self._executor_internal(host, new_stdin)
  File "/home/Technique/Code/ansible/lib/ansible/runner/__init__.py", line 792, in _executor_internal
    return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
  File "/home/Technique/Code/ansible/lib/ansible/runner/__init__.py", line 1063, in _executor_internal_inner
    self.callbacks.on_unreachable(host, result.result)
  File "/home/Technique/Code/ansible/lib/ansible/callbacks.py", line 460, in on_unreachable
    results = utils.to_bytes(results)
  File "/home/Technique/Code/ansible/lib/ansible/utils/__init__.py", line 1284, in to_bytes
    return value.encode('utf-8')
AttributeError: 'dict' object has no attribute 'encode'
FATAL: all hosts have already failed -- aborting

Haven't looked a lot further, as I was in a hurry, so I just renamed my files.. It also happens if the directory you're work in has accents in it (I had something like /home/gilles/Technique/Déploiement, and it wouldn't work).
Might get into it deeper if I have time..

@bcoca bcoca added P2 Priority 2 - Issue Blocks Release bug_report labels Jan 27, 2015
@abadger
Copy link
Contributor

abadger commented Jan 27, 2015

Ugh, this is happening in part because of a fix I just added I think. Somewhat strange that this is only triggering with non-ascii though. Although the code deals with encoding and decoding I would expect that dict vs string would be independent of whether the value was non-ascii.

I'll see if I can reproduce. If so I should be able to get out a quick fix.

@abadger
Copy link
Contributor

abadger commented Jan 27, 2015

Ugh. Okay, this is going to be a bit harder than I thought. I was able to fix the initial traceback rather quickly here: 35321ec

But that was just hiding the real error:

$ ansible-playbook utf8.yml                            *[devel]  (14:16:10)

PLAY [localhost] ************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [localhost]

TASK: [Test utf] ************************************************************** 
fatal: [localhost] => {'msg': "UnicodeEncodeError: 'ascii' codec can't encode character u'\\xe9' in position 29: ordinal not in range(128)", 'failed': True}
fatal: [localhost] => {'msg': "UnicodeEncodeError: 'ascii' codec can't encode character u'\\xe9' in position 29: ordinal not in range(128)", 'failed': True}

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/badger/utf8.retry

localhost                  : ok=1    changed=0    unreachable=1    failed=0

@abadger
Copy link
Contributor

abadger commented Jan 28, 2015

That commit should finish off the fix. I also tested this in the v2 tree and everything worked as expected there.

Closing This Ticket

Hi!

We believe recent commits (likely detailed above) should resolve this question or problem for you.

This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular
issue is resolved.

Thank you!

@gilou
Copy link
Contributor Author

gilou commented Jan 29, 2015

Works on the devel branch for me, thanks ;)

@L-B
Copy link

L-B commented Apr 26, 2018

Hello,

I'm still having issues with that on 2.5.1, as per #27262 that I opened last year. Anything I can do to help getting it fixed?

Thanks

@yodatak
Copy link

yodatak commented May 23, 2018

Same on 2.5.2

@L-B
Copy link

L-B commented May 23, 2018

@yodatak: it's been dealt with in #27262 and the fix has just been released in 2.5.3.

@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release
Projects
None yet
Development

No branches or pull requests

6 participants