Can you try setting "module_lang = en_US.UTF-8" in your ansible.cfg to see
if that corrects the issue?


On Mon, May 12, 2014 at 2:30 PM, Joel Sdc <[email protected]> wrote:

> Hi,
>
> I'm having a little problem. When I run a simple playbook, on some servers
> I get a UnicodeEncodeError and the playbook is not executed.
>
> I have the role "users_admin", it creates 3 groups, makes sure that 4
> users exist and have a specific password and set a root password if it has
> changed.
>
> root@cm:/etc/ansible/roles/users_admin# tree
> .
> └── tasks
>     └── main.yml
>
> 1 directory, 1 file
> root@cm:/etc/ansible/roles/users_admin# cat tasks/main.yml
> ---
> - name: Global group 'admins'
>   group: name=admins state=present gid=2000
>
> - name: Global group 'support'
>   group: name=support state=present gid=2001
>
> - name: Global group 'developers'
>   group: name=developers state=present gid=2002
>
> - name: Common 'admin' users
>   user: name={{ item.name }} comment={{ item.gecos }} group=admins
> state=present uid={{ item.uid }} update_password=always password={{
> item.passwd }} shell=/bin/bash
>   with_items:
>         - name: test1
>           gecos: "test1"
>           uid: 2050
>           passwd:
> $6$2trU.wqo$c.QAHAngzhx.i6VwGM9zGoh8KdX3e.2EAnzYf3SDdIBWZFVo4OdHQjPxVl/8wmmD6hWYnxeyMF9rLAfNMk3oa0
>
>         - name: test2
>           gecos: "test2"
>           uid: 2051
>           passwd:
> $6$xIKLieVe$oFdw1N/FjdPQzdMGkViaG8UMTMwGhNBKvtVxMIbcDFTu3udXYtrH5un0Obmr6d9gDC66DK/dNfpP6jlESRtan/
>
>         - name: test3
>           gecos: "test3"
>           uid: 2052
>           passwd:
> $6$9bJs8kiu$lS.Jz.cGdx5J3s.Mw5V80GzO.U6tLLMwztuDZJsAe2JjpYLCedR96fAHbHVaozv0zRUrtexErdgTYQU0o0tCh0
>
>         - name: test4
>           gecos: "test4"
>           uid: 2053
>           passwd:
> $6$tmUQlubJ$0HI532QrAnlTGHwJlLEuGU2/uSAr42I2Y6aEFBbPlmXborYOlmVeCl5vI.YBLo3HDTFt/mx98HXv7yMqqgifa/
>
> - name: Set root password
>   user: name=root update_password=always
> password=$6$HqRU2uvR$6GV6CYTbtkxpbX7POk9FGglzK3M4G8icIuEWlxnllDe4FswqsQQbIaEsbT/JhaQe9ot4pAS8A/1RDurOb1e/p.
>
> root@cm:/etc/ansible/roles/users_admin#
>
> And this is the playbook:
>
> root@cm:/etc/ansible/playbooks# cat test.yml
> ---
> - name: Common settings
>   hosts: all
>   roles:
>     - users_admin
> root@cm:/etc/ansible/playbooks#
>
> When I run the playbook, It fails in a newly installed Debian 7.5:
>
> root@cm:/etc/ansible/playbooks# ansible-playbook test.yml
>
> PLAY [Common settings]
> ********************************************************
>
> GATHERING FACTS
> ***************************************************************
> ok: [test]
>
> TASK: [users_admin | Global group 'admins'] ***************
> ok: [test]
>
> TASK: [users_admin | Global group 'support'] **************
> ok: [test]
>
> TASK: [users_admin | Global group 'developers'] ***********
> ok: [test]
>
> TASK: [users_admin | Common 'admin' users] ****************
> fatal: [test] => Traceback (most recent call last):
>   File "/usr/lib/pymodules/python2.7/ansible/runner/__init__.py", line
> 532, in _executor
>     exec_rc = self._executor_internal(host, new_stdin)
>   File "/usr/lib/pymodules/python2.7/ansible/runner/__init__.py", line
> 660, in _executor_internal
>     complex_args=complex_args
>   File "/usr/lib/pymodules/python2.7/ansible/runner/__init__.py", line
> 809, in _executor_internal_inner
>     module_args = template.template(self.basedir, module_args, inject,
> fail_on_undefined=self.error_on_undefined_vars)
>   File "/usr/lib/pymodules/python2.7/ansible/utils/template.py", line 321,
> in template
>     varname = template_from_string(basedir, varname, vars,
> fail_on_undefined)
>   File "/usr/lib/pymodules/python2.7/ansible/utils/template.py", line 543,
> in template_from_string
>     data = data.decode('utf-8')
>   File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
>     return codecs.utf_8_decode(input, errors, True)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in
> position 83: ordinal not in range(128)
>
>
> FATAL: all hosts have already failed -- aborting
>
> PLAY RECAP
> ********************************************************************
>            to retry, use: --limit @/root/test.retry
>
> test                       : ok=4    changed=0    unreachable=1    failed=0
>
> root@cm:/etc/ansible/playbooks#
>
> Googling I found:
> http://mypy.pythonblogs.com/12_mypy/archive/1253_workaround_for_python_bug_ascii_codec_cant_encode_character_uxa0_in_position_111_ordinal_not_in_range128.html
>
> Output:
>
> root@test:~# python
> Python 2.7.3 (default, Mar 13 2014, 11:03:55)
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> sys.getdefaultencoding()
> 'ascii'
> >>>
> root@test:~#
>
> root@test:~# echo $LANG
> en_US.UTF-8
> root@test:~#
>
> My Ansible version:
>
> root@cm:/etc/ansible# ansible-playbook --version
> ansible-playbook 1.5.5
> root@cm:/etc/ansible#
>
>
>
> Any idea what I'm doing wrong?
>
> If it helps, this problem does NOT occur on every server, It could be
> something misconfigured on the client side as the same playbook works
> perfectly on other servers.
>
> Thanks in advanced.
>
> Best regards,
> Joel.
>
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f7e9ae39-f234-4f09-a414-2cbaba9dc8a4%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/f7e9ae39-f234-4f09-a414-2cbaba9dc8a4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAMFyvFjwj0xv1hyodKADZxJKYf_Gz0yjdxs_U_CdFXvnoq_uQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to