mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
Some minor refactoring of playbook code, more to go.
This commit is contained in:
parent
c57df6220b
commit
0d7a84d591
2 changed files with 42 additions and 40 deletions
|
@ -36,20 +36,26 @@ def exit(msg, rc=1):
|
|||
err(msg)
|
||||
sys.exit(rc)
|
||||
|
||||
def _bigjson(result):
|
||||
def bigjson(result):
|
||||
''' format JSON output (uncompressed) '''
|
||||
return json.dumps(result, sort_keys=True, indent=4)
|
||||
|
||||
def _json(result):
|
||||
def smjson(result):
|
||||
''' format JSON output (compressed) '''
|
||||
return json.dumps(result, sort_keys=True)
|
||||
|
||||
def task_start_msg(name, conditional):
|
||||
if conditional:
|
||||
return "NOTIFIED: [%s] **********\n" % name
|
||||
else:
|
||||
return "TASK: [%s] *********\n" % name
|
||||
|
||||
def regular_generic_msg(hostname, result, oneline, caption):
|
||||
''' output on the result of a module run that is not command '''
|
||||
if not oneline:
|
||||
return "%s | %s >>\n%s" % (hostname, caption, _bigjson(result))
|
||||
return "%s | %s >>\n%s" % (hostname, caption, bigjson(result))
|
||||
else:
|
||||
return "%s | %s >> %s" % (hostname, caption, _json(result))
|
||||
return "%s | %s >> %s" % (hostname, caption, smjson(result))
|
||||
|
||||
def regular_success_msg(hostname, result, oneline):
|
||||
''' output the result of a successful module run '''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue