salt.engines.script

Send events based on a script's stdout

Example Config

engines:
  - script:
      cmd: /some/script.py -a 1 -b 2
      output: json
      interval: 5
      onchange: false

Script engine configs:

cmd

Script or command to execute

output

Any available saltstack deserializer

interval

How often in seconds to execute the command

onchange

New in version 3006.0.

Only fire an event if the tag-specific output changes. Defaults to False.

salt.engines.script.start(cmd, output='json', interval=1, onchange=False)

Parse stdout of a command and generate an event

The script engine will scrap stdout of the given script and generate an event based on the presence of the 'tag' key and its value.

If there is a data obj available, that will also be fired along with the tag.

Example

Given the following json output from a script:

{ "tag" : "lots/of/tacos",
"data" : { "toppings" : "cilantro" }
}

This will fire the event 'lots/of/tacos' on the event bus with the data obj as is.

Parameters:
  • cmd -- The command to execute

  • output -- How to deserialize stdout of the script

  • interval -- How often to execute the script

  • onchange -- Only fire an event if the tag-specific output changes