Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified 'ok' to 'changed' when a change has occured #1081

Merged
merged 1 commit into from
Sep 24, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/ansible/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,25 +310,29 @@ def on_ok(self, host, host_result):

host_result2 = host_result.copy()
host_result2.pop('invocation', None)
changed = 'changed' in host_result2 or host_result['changed']
ok_or_changed = 'ok'
if changed:
ok_or_changed = 'changed'

# show verbose output for non-setup module results if --verbose is used
msg = ''
if not self.verbose or host_result2.get("verbose_override",None) is not None:
if item:
msg = "ok: [%s] => (item=%s)" % (host,item)
msg = "ok: [%s] => (item=%s)" % (host, item)
else:
if 'ansible_job_id' not in host_result or 'finished' in host_result:
msg = "ok: [%s]" % (host)
msg = "%s: [%s]" % (ok_or_changed, host)
else:
# verbose ...
if item:
msg = "ok: [%s] => (item=%s) => %s" % (host, item, utils.jsonify(host_result2))
msg = "%s: [%s] => (item=%s) => %s" % (ok_or_changed, host, item, utils.jsonify(host_result2))
else:
if 'ansible_job_id' not in host_result or 'finished' in host_result2:
msg = "ok: [%s] => %s" % (host, utils.jsonify(host_result2))
msg = "%s: [%s] => %s" % (host, utils.jsonify(host_result2))

if msg != '':
if not 'changed' in host_result2 or not host_result['changed']:
if not changed:
print stringc(msg, 'green')
else:
print stringc(msg, 'yellow')
Expand Down