salt.modules.publish

Publish a command from a minion to a target

salt.modules.publish.full_data(tgt, fun, arg=None, tgt_type=u'glob', returner=u'', timeout=5, expr_form=None)

Return the full data about the publication, this is invoked in the same way as the publish function

CLI Example:

salt system.example.com publish.full_data '*' cmd.run 'ls -la /tmp'

Attention

If you need to pass a value to a function argument and that value contains an equal sign, you must include the argument name. For example:

salt '*' publish.full_data test.kwarg arg='cheese=spam'
salt.modules.publish.publish(tgt, fun, arg=None, tgt_type=u'glob', returner=u'', timeout=5, via_master=None, expr_form=None)

Publish a command from the minion out to other minions.

Publications need to be enabled on the Salt master and the minion needs to have permission to publish the command. The Salt master will also prevent a recursive publication loop, this means that a minion cannot command another minion to command another minion as that would create an infinite command loop.

The tgt_type argument is used to pass a target other than a glob into the execution, the available options are:

  • glob
  • pcre
  • grain
  • grain_pcre
  • pillar
  • pillar_pcre
  • ipcidr
  • range
  • compound

Changed in version 2017.7.0: The expr_form argument has been renamed to tgt_type, earlier releases must use expr_form.

Note that for pillar matches must be exact, both in the pillar matcher and the compound matcher. No globbing is supported.

The arguments sent to the minion publish function are separated with commas. This means that for a minion executing a command with multiple args it will look like this:

salt system.example.com publish.publish '*' user.add 'foo,1020,1020'
salt system.example.com publish.publish 'os:Fedora' network.interfaces '' grain

CLI Example:

salt system.example.com publish.publish '*' cmd.run 'ls -la /tmp'

Attention

If you need to pass a value to a function argument and that value contains an equal sign, you must include the argument name. For example:

salt '*' publish.publish test.kwarg arg='cheese=spam'

Multiple keyword arguments should be passed as a list.

salt '*' publish.publish test.kwarg arg="['cheese=spam','spam=cheese']"

When running via salt-call, the via_master flag may be set to specific which master the publication should be sent to. Only one master may be specified. If unset, the publication will be sent only to the first master in minion configuration.

salt.modules.publish.runner(fun, arg=None, timeout=5)

Execute a runner on the master and return the data from the runner function

CLI Example:

salt publish.runner manage.down