<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.6.10</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Running: OS X<br>
Managing: Ubuntu 13.10</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Running the <code class="notranslate">GATHERING FACTS</code> command can cause an exception and print a traceback if the managed server is out of disk space.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">Set up a server and exhaust the disk space.  Run a playbook to gather facts.  The traceback generated was:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
File &quot;/Users/maspwr/venv/bin/ansible-playbook&quot;, line 317, in &lt;module&gt;
sys.exit(main(sys.argv[1:]))
File &quot;/Users/maspwr/venv/bin/ansible-playbook&quot;, line 257, in main
pb.run()
File &quot;/Users/maspwr/venv/lib/python2.7/site-packages/ansible/playbook/__init__.py&quot;, line 323, in run
if not self._run_play(play):
File &quot;/Users/maspwr/venv/lib/python2.7/site-packages/ansible/playbook/__init__.py&quot;, line 624, in _run_play
self._do_setup_step(play)
File &quot;/Users/maspwr/venv/lib/python2.7/site-packages/ansible/playbook/__init__.py&quot;, line 569, in _do_setup_step
accelerate_port=play.accelerate_port,
File &quot;/Users/maspwr/venv/lib/python2.7/site-packages/ansible/runner/__init__.py&quot;, line 1286, in run

File &quot;/Users/maspwr/venv/lib/python2.7/site-packages/ansible/runner/__init__.py&quot;, line 576, in _executor
return ReturnData(host=host, comm_ok=False, result=dict(failed=True, msg=msg))
File &quot;/Users/maspwr/venv/lib/python2.7/site-packages/ansible/callbacks.py&quot;, line 464, in on_unreachable
msg = &quot;fatal: [%s] =&gt; %s&quot; % (host, results)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 514: ordinal not in range(128)"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
File "/Users/maspwr/venv/bin/ansible-playbook", line 317, in &lt;module&gt;
sys.exit(main(sys.argv[1:]))
File "/Users/maspwr/venv/bin/ansible-playbook", line 257, in main
pb.run()
File "/Users/maspwr/venv/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 323, in run
if not self._run_play(play):
File "/Users/maspwr/venv/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 624, in _run_play
self._do_setup_step(play)
File "/Users/maspwr/venv/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 569, in _do_setup_step
accelerate_port=play.accelerate_port,
File "/Users/maspwr/venv/lib/python2.7/site-packages/ansible/runner/__init__.py", line 1286, in run

File "/Users/maspwr/venv/lib/python2.7/site-packages/ansible/runner/__init__.py", line 576, in _executor
return ReturnData(host=host, comm_ok=False, result=dict(failed=True, msg=msg))
File "/Users/maspwr/venv/lib/python2.7/site-packages/ansible/callbacks.py", line 464, in on_unreachable
msg = "fatal: [%s] =&gt; %s" % (host, results)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 514: ordinal not in range(128)
</code></pre></div>
<p dir="auto">Setting a breakpoint on line 576 in <code class="notranslate">/Users/maspwr/venv/lib/python2.7/site-packages/ansible/runner/__init__.py</code> and doing a <code class="notranslate">p msg</code> shows this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="'Authentication or permission failure.  In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in &quot;/tmp&quot;. Failed command was: mkdir -p $HOME/.ansible/tmp/ansible-tmp-1406922950.16-11753546351226 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1406922950.16-11753546351226 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1406922950.16-11753546351226, exited with result 1: mkdir: cannot create directory \xe2\x80\x98/home/comprehend/.ansible/tmp/ansible-tmp-1406922950.16-11753546351226\xe2\x80\x99: No space left on device\r\n'"><pre class="notranslate"><code class="notranslate">'Authentication or permission failure.  In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in "/tmp". Failed command was: mkdir -p $HOME/.ansible/tmp/ansible-tmp-1406922950.16-11753546351226 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1406922950.16-11753546351226 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1406922950.16-11753546351226, exited with result 1: mkdir: cannot create directory \xe2\x80\x98/home/comprehend/.ansible/tmp/ansible-tmp-1406922950.16-11753546351226\xe2\x80\x99: No space left on device\r\n'
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">If there was no space left on the target machine, I'd expect any error generated to be displayed as such instead of ansible crashing due to a <code class="notranslate">UnicodeDecodeError</code>.</p>
<h5 dir="auto">Actual Results:</h5>
<p dir="auto">Ansible crashes with the above traceback.</p>
<h5 dir="auto">Issue Type: Bug Report</h5>
<h5 dir="auto">Ansible Version: ansible 1.8.4</h5>
<h5 dir="auto">Ansible Configuration: Nothing</h5>
<h5 dir="auto">Environment: Darwin redacted 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64</h5>
<h5 dir="auto">Summary:</h5>
<p dir="auto">When resolving a variable from <code class="notranslate">another_host</code> via <code class="notranslate">hostvars</code> - if that variable is built up from other variables, those are resolved in the content of the <code class="notranslate">current_host</code> instead of <code class="notranslate">another_host</code></p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">Please see <a href="https://github.com/dwt/ansible-reproduction-variable-resolution">https://github.com/dwt/ansible-reproduction-variable-resolution</a> for a reduction.</p>
<p dir="auto">Calling that playbook will demonstrate the problem in the output.</p>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Using <code class="notranslate">hostvars</code> should not change the way variables are evaluated, as that means you can't really get the variables from another host as he would see them, which makes this feature rather dangerous. Instead it should allow to access variables as if another host would access them.</p>
<h5 dir="auto">Actual Results:</h5>
<p dir="auto">If a variable is a composition of other variables, accessing it through <code class="notranslate">hostvars</code> will resolve those other variables in the context of the current host, thus giving unexpected (and sometimes dangerous) results.</p>