diff --git a/salt/client/ssh/wrapper/publish.py b/salt/client/ssh/wrapper/publish.py index b88ec2c49f..763ba4482d 100644 --- a/salt/client/ssh/wrapper/publish.py +++ b/salt/client/ssh/wrapper/publish.py @@ -12,8 +12,10 @@ No access control is needed because calls cannot originate from the minions. # Import python libs import copy import logging + # Import salt libs import salt.client.ssh +import salt.runner log = logging.getLogger(__name__) @@ -206,3 +208,27 @@ def full_data(tgt, timeout=timeout, form='full', roster=roster) + + +def runner(fun, arg=None, timeout=5): + ''' + Execute a runner on the master and return the data from the runnr function + + CLI Example: + + .. code-block:: bash + + salt-ssh '*' publish.runner jobs.lookup_jid 20140916125524463507 + ''' + # Form args as list + if not isinstance(arg, list): + arg = [salt.utils.args.yamlify_arg(arg)] + else: + arg = [salt.utils.args.yamlify_arg(x) for x in arg] + if len(arg) == 1 and arg[0] is None: + arg = [] + + # Create and run the runner + runner = salt.runner.RunnerClient(__opts__['__master_opts__']) + return runner.cmd(fun, arg) +