Not seeing errors when a ping command fails

28 views
Skip to first unread message

Rupert Swarbrick

unread,
Jul 2, 2015, 9:04:54 AM7/2/15
to ansible...@googlegroups.com
Hi,

I'm new to Ansible, so might be asking a slightly silly question here. I've just started setting up an environment based on the development version (sha 08ad05c) and did the obvious "hello world test":

  $ ansible all -i inventory -m ping

The result was... nothing. A bit confusing, so I intentionally set the wrong host in my inventory, and got the same result. Adding -vvvv doesn't produce any output, and I had to dig around with traceback.print_stack and ANSIBLE_DEBUG=True to figure out what was going on. It turns out that I don't have paths set up correctly for Paramiko. I'll fix that myself in a minute, but the error handling doesn't seem to be working properly? (Or at least, it's distinctly unhelpful)

With ANSIBLE_DEBUG=True, I see:

<snip>
 24113 1435841636.49516: done running TaskExecutor() for evm0/TASK: ping
 24113 1435841636.49518: sending task result
 24113 1435841636.49561: done sending task result
 24108 1435841636.50319: waiting for pending results (1 left)
 24108 1435841636.51335: waiting for pending results (1 left)
 24118 1435841636.52105: worker 1 has data to read
 24118 1435841636.52285: got a result from worker 1: <ansible.executor.task_result.TaskResult object at 0x198fe90>
 24118 1435841636.52295: sending result: ('host_task_failed', <ansible.executor.task_result.TaskResult object at 0x198fe90>)
 24118 1435841636.52352: done sending result
 24108 1435841636.52357: waiting for pending results (1 left)
 24108 1435841636.53373: waiting for pending results (1 left)
 24108 1435841636.53505: got result from result worker: ('host_task_failed', <ansible.executor.task_result.TaskResult object at 0x1ec2810>)
 24108 1435841636.53514: marking evm0 as failed
 24108 1435841636.54546: results queue empty
 24108 1435841636.54547: getting the remaining hosts for this loop
 24108 1435841636.54558: done getting the remaining hosts for this loop
 24108 1435841636.54617: done queuing things up, now waiting for results queue to drain
 24108 1435841636.54619: results queue empty
 24108 1435841636.54620: running handlers
 24108 1435841636.54630: RUNNING CLEANUP

To figure out what was going wrong, I eventually found TaskExecutor's run() method in executor/task_executor.py and printed the error it was catching.

The error message gets bundled up into the TaskResult that we can see being passed around above. This makes it as far upwards as the run method of StrategyModule in plugins/strategies/linear.py. There it is added to a variable called host_results. Since the result isn't an "include result" (which I don't know much about), the call to process_include_results() doesn't do anything. And then the result is discarded.

Should the user have some way of telling that the command failed? Or am I using the tool wrong?


Rupert

Brian Coca

unread,
Jul 4, 2015, 10:31:24 AM7/4/15
to ansible...@googlegroups.com
rebase and try again, adhoc output was broken for a short time in the
repo but it should be working now.
you should get a message when running normally and you should use
-vvvv to get all the details.



--
Brian Coca

Rupert Swarbrick

unread,
Jul 4, 2015, 5:09:48 PM7/4/15
to ansible...@googlegroups.com
Ah, brilliant. I'll try it out when I get back to work on Monday. Thanks for the quick fix!

Rupert
Reply all
Reply to author
Forward
0 new messages