output: new state output 'changes'

It displays states result in 'full' mode unless nothing changed, in
which case it displays results in 'terse' mode.
This commit is contained in:
Jonathan Ballet 2013-06-17 15:22:57 +02:00
parent c09323d276
commit 5f473bb17e
2 changed files with 8 additions and 0 deletions

View File

@ -358,6 +358,7 @@ The state_output setting changes if the output is the full multi line
output for each changed state if set to 'full', but if set to 'terse'
the output will be shortened to a single line. If set to 'mixed', the output
will be terse unless a state failed, in which case that output will be full.
If set to 'changes', the output will be fill unless the state didn't change.
.. code-block:: yaml

View File

@ -86,6 +86,13 @@ def output(data):
msg = _format_terse(tcolor, comps, ret, colors)
hstrs.append(msg)
continue
elif __opts__.get('state_output', 'full').lower() == 'changes':
# Print terse if no error and no changes, otherwise, be
# verbose
if ret['result'] is not False and not ret['changes']:
msg = _format_terse(tcolor, comps, ret, colors)
hstrs.append(msg)
continue
hstrs.append(('{0}----------\n State: - {1}{2[ENDC]}'
.format(tcolor, comps[0], colors)))
hstrs.append(' {0}Name: {1}{2[ENDC]}'.format(