# Buggy code
def print_msg(template, msg):
    print(template.format(msg.rstrip()))


# Traceback (UnicodeEncodeError)
TASK [ansible-jdk-localinstall : Check whether JDK is installed] ***************
task path: /Users/miqueladrover/Projects/ansible/ansible_sacyl_cassandra/roles/ansible-jdk-localinstall/tasks/redhat/package.yml:2
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: vagrant
<127.0.0.1> SSH: EXEC ssh -C -vvv -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/Users/miqueladrover/Projects/ansible/ansible_sacyl_cassandra/.vagrant/machines/cassandra/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=30 -o ControlPath=/Users/miqueladrover/.ansible/cp/ansible-ssh-%h-%p-%r 127.0.0.1 '/bin/sh -c '"'"'( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1482966597.61-166470479582663 `" &amp;&amp; echo ansible-tmp-1482966597.61-166470479582663="` echo $HOME/.ansible/tmp/ansible-tmp-1482966597.61-166470479582663 `" ) &amp;&amp; sleep 0'"'"''
<127.0.0.1> PUT /var/folders/73/j851knkj11755mllmt85t9kh0000gn/T/tmpeMDtd4 TO /home/vagrant/.ansible/tmp/ansible-tmp-1482966597.61-166470479582663/command
<127.0.0.1> SSH: EXEC sftp -b - -C -vvv -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/Users/miqueladrover/Projects/ansible/ansible_sacyl_cassandra/.vagrant/machines/cassandra/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=30 -o ControlPath=/Users/miqueladrover/.ansible/cp/ansible-ssh-%h-%p-%r '[127.0.0.1]'
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: vagrant
<127.0.0.1> SSH: EXEC ssh -C -vvv -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/Users/miqueladrover/Projects/ansible/ansible_sacyl_cassandra/.vagrant/machines/cassandra/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=30 -o ControlPath=/Users/miqueladrover/.ansible/cp/ansible-ssh-%h-%p-%r 127.0.0.1 '/bin/sh -c '"'"'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1482966597.61-166470479582663/ /home/vagrant/.ansible/tmp/ansible-tmp-1482966597.61-166470479582663/command &amp;&amp; sleep 0'"'"''
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: vagrant
<127.0.0.1> SSH: EXEC ssh -C -vvv -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/Users/miqueladrover/Projects/ansible/ansible_sacyl_cassandra/.vagrant/machines/cassandra/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=30 -o ControlPath=/Users/miqueladrover/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-axlabkfvmbhpvectbdgxmeahvqmiqbfz; LANG=es_ES.UTF-8 LC_ALL=es_ES.UTF-8 LC_MESSAGES=es_ES.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1482966597.61-166470479582663/command; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1482966597.61-166470479582663/" > /dev/null 2>&amp;1'"'"'"'"'"'"'"'"' &amp;&amp; sleep 0'"'"''
Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/site-packages/sh.py", line 1484, in output_thread
done = stream.read()
File "/usr/local/lib/python2.7/site-packages/sh.py", line 1974, in read
self.write_chunk(chunk)
File "/usr/local/lib/python2.7/site-packages/sh.py", line 1949, in write_chunk
self.should_quit = self.process_chunk(chunk)
File "/usr/local/lib/python2.7/site-packages/sh.py", line 1867, in process
return handler(chunk)
File "/usr/local/lib/python2.7/site-packages/sh.py", line 1106, in fn
return handler(chunk, *args)
File "/usr/local/lib/python2.7/site-packages/molecule/util.py", line 81, in callback_info
print_info(msg, pretty=False)
File "/usr/local/lib/python2.7/site-packages/molecule/util.py", line 45, in print_info
print_msg('{}', msg)
File "/usr/local/lib/python2.7/site-packages/molecule/util.py", line 76, in print_msg
print(template.format(msg.rstrip()))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 480: ordinal not in range(128)

# Fixed code
def print_msg(template, msg):
    print(template.format(msg.rstrip().encode("utf-8")))