Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

retries loop

ANSIBLE VERSION

ansible 2.4.2.0
python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]

CONFIGURATION

default

OS / ENVIRONMENT

Debian 9

SUMMARY

While using retries loop in a task, attempts key from registered variable is not defined during first iteration. On Ansible 1.9.6, it was.

In task_executor.py, attempts key is defined only if retries > 1: .

This is a problem with my use case:

I need to check that a host successfully went down after ordering reboot. This task can take some time, and the modules (ping) and or shell commands (nc, ...) raise an error when the host enters the expected state. So I use the retries loop with failed_when to override the fail behaviour.

STEPS TO REPRODUCE

Run the following task with Ansible >= 2.0. Destination host is up.

- name: Wait for instance to shutdown
shell: 'nc -w 1 -zv {{ ansible_ssh_host }} 22'
register: connection_shutdown
failed_when: connection_shutdown.attempts >= 5
until: connection_shutdown.stderr.find("succeeded") == -1
delegate_to: 127.0.0.1
retries: 5

EXPECTED RESULTS

Rebooting host between 1st and 2nd iteration of "Wait for instance to shutdown".

PLAY [Issue] ***********************************************************************************************

TASK [Gathering Facts] *********************************************************************************************
ok: [host1]

TASK [Wait for instance to shutdown] *******************************************************************************
FAILED - RETRYING: Wait for instance to shutdown (5 retries left).
##### Rebooting host1 #####
changed: [host1 -> 127.0.0.1]

PLAY RECAP *********************************************************************************************************
host1 : ok=2 changed=1 unreachable=0 failed=0

ACTUAL RESULTS

PLAY [Issue] ***********************************************************************************************

TASK [Gathering Facts] *********************************************************************************************
ok: [host1]

TASK [Wait for instance to shutdown] *******************************************************************************
fatal: [host1]: FAILED! => {"msg": "The conditional check 'connection_shutdown.attempts >= 5' failed. The error was: error while evaluating conditional (connection_shutdown.attempts >= 5): 'dict object' has no attribute 'attempts'"}
to retry, use: --limit @/home/gmathon/ansible/test.retry

PLAY RECAP *********************************************************************************************************
host1 : ok=1 changed=0 unreachable=0 failed=1

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

default output plugin? I'm not sure exactly what this is called.

ANSIBLE VERSION

all versions are affected. that's part of the problem.

CONFIGURATION

I'm complaining about an inane default. no configuration problems required

OS / ENVIRONMENT

all

SUMMARY

ansible error output is impossible to read. Why oh why can the JSON output not at least by pretty by default?

STEPS TO REPRODUCE

run any playbook that gives an error

EXPECTED RESULTS

could we have pretty formatting like this:

{

'changed': true,

"cmd": ["rpmbuild", "-ba", "SPECS/thing.spec"],

"delta": "0:00:00.361828",

"stderr":"""

Lots of output

from the program in question

And newlines are interpreted properly!

"""

}

ACTUAL RESULTS

An unreadable JSON dump. I don't think I really need to put an example.

My efforts to push for adoption of ansible in my organization have been thoroughly hindered by this problem - people can't read the error messages they get and so do not use the tool.

You cannot hope to see all the people who are being turned off by this. Most of them simply stop using and go away.

Others (e.g. http://blog.cliffano.com/2014/04/06/human-readable-ansible-playbook-log-output-using-callback-plugin/) have provided acceptable fixes for this with callback plugins (but it absolutely must be the default, or any solution is moot). It is time for this ridiculous problem to be solved. Please please please.