Issue 1:
Issue Type:

Bug Report

Ansible Version:

ansible 1.6.10

Environment:

Running: OS X

Managing: Ubuntu 13.10

Summary:

Running the GATHERING FACTS command can cause an exception and print a traceback if the managed server is out of disk space.

Steps To Reproduce:

Set up a server and exhaust the disk space. Run a playbook to gather facts. The traceback generated was:

Traceback (most recent call last):
File "/Users/maspwr/venv/bin/ansible-playbook", line 317, in <module>
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] => %s" % (host, results)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 514: ordinal not in range(128)

Setting a breakpoint on line 576 in /Users/maspwr/venv/lib/python2.7/site-packages/ansible/runner/__init__.py and doing a p msg shows this:

'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 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1406922950.16-11753546351226 && 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'

Expected Results:

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 UnicodeDecodeError.

Actual Results:

Ansible crashes with the above traceback.

Issue 2:
Issue Type: Bug Report

Ansible Version: ansible 1.8.4

Ansible Configuration: Nothing

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

Summary:

When resolving a variable from another_host via hostvars - if that variable is built up from other variables, those are resolved in the content of the current_host instead of another_host

Steps To Reproduce:

Please see https://github.com/dwt/ansible-reproduction-variable-resolution for a reduction.

Calling that playbook will demonstrate the problem in the output.

Expected Results:

Using hostvars 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.

Actual Results:

If a variable is a composition of other variables, accessing it through hostvars will resolve those other variables in the context of the current host, thus giving unexpected (and sometimes dangerous) results.