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.
On Tuesday, 31 December 2019 01:50:24 UTC+10:30, Andrew Graham wrote:
>
> 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!
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/59a8ac94-d8af-47b0-8736-002ede74ffc8%40googlegroups.com.