Your first returner
Go ahead and open up salt/returners/local.py
. There's not much in here, but what we're interested in is the returner()
function. It's very, very small:
def returner(ret): ''' Print the return data to the terminal to verify functionality ''' print(ret)
In fact, all it does is accept return data as ret
, and then print it to the console. It doesn't even attempt any sort of pretty printing; it just dumps it as is.
This is in fact the bare minimum that a returner needs: a returner()
function that accepts a dictionary, and then does something with it. Let's go ahead and create our own returner, which stores job information locally in JSON format.
''' Store return data locally in JSON format This file should be saved as salt/returners/local_json.py ''' import json import salt.utils def returner(ret): ''' Open new file, and save return data to it in JSON format ''' path = '/tmp/salt-{0}-{1}.json'.format(ret['jid'], ret['id']) with salt.utils...