unicode errors and inconsistency.

35 views
Skip to first unread message

Andrew Graham

unread,
Dec 30, 2019, 10:20:24 AM12/30/19
to Ansible Project
I get errors when passing some passwords into a shell command and I'd love some pointers on the best way out.  The strange thing is, the ansible script works fine on centos 7 in AWS, but not on RHEL 7 on my local machine, and not in my ansible control vagrant virtualbox host (ubuntu 16).

here is an example, the password creates issues.


- name: Query houdini filename - Houdini python script
 shell
: |
 cd
/opt/houdini_install_script/
 python
/opt/houdini_install_script/houdini_install.py -u '{{ sesi_username }}' -p '{{ sesi_password }}' -i /opt/houdini
 
register: houdini_query_out
 become
: true
 
when: houdini_version_item.houdini_auto_version


This will produce unicode errors like this -

fatal: [workstation]: FAILED! => {}

MSG:

An unhandled exception occurred while templating '{{ lookup('env','TF_VAR_sesi_password') }}'. Error was a <type 'exceptions.UnicodeDecodeError'>, original message: 'ascii' codec can't decode byte 0xe2 in position 4: ordinal not in range(128)


Annoyingly, if I b64encode the sesi_password and then b64decode it in the shell, this then flips the scenario around - it will then work locally in ubuntu 16 and rhel 7, but not in the centos 7 AWS AMI in stead!

Andrew Graham

unread,
Dec 30, 2019, 11:00:01 AM12/30/19
to Ansible Project
I was mistaken, the inconsistency was due to the password var being passed to ansible as extra-vars, this solves the unicode problem and avoids the conversion (default vars get converted to unicode, they cause the problem).  I'd like to avoid specifying the password in extra-vars though for security, so I'd love to know an approach to fixing the default vars handling this better.

Andrew Graham

unread,
Jan 8, 2020, 6:07:43 AM1/8/20
to Ansible Project
Has anyone else run into something similar?


On Tuesday, 31 December 2019 01:50:24 UTC+10:30, Andrew Graham wrote:
Reply all
Reply to author
Forward
0 new messages