salt.runners.jobs

A convenience system to manage jobs, both active and already run

salt.runners.jobs.active(display_progress=False)

Return a report on all actively running jobs from a job id centric perspective

CLI Example:

salt-run jobs.active
salt.runners.jobs.exit_success(jid, ext_source=None)

Check if a job has been executed and exit successfully

jid

The jid to look up.

ext_source

The external job cache to use. Default: None.

CLI Example:

salt-run jobs.exit_success 20160520145827701627
salt.runners.jobs.last_run(ext_source=None, outputter=None, metadata=None, function=None, target=None, display_progress=False)

New in version 2015.8.0.

List all detectable jobs and associated functions

CLI Example:

salt-run jobs.last_run
salt-run jobs.last_run target=nodename
salt-run jobs.last_run function='cmd.run'
salt-run jobs.last_run metadata="{'foo': 'bar'}"
salt.runners.jobs.list_job(jid, ext_source=None, display_progress=False)

List a specific job given by its jid

ext_source

If provided, specifies which external job cache to use.

display_progressFalse

If True, fire progress events.

New in version 2015.8.8.

CLI Example:

salt-run jobs.list_job 20130916125524463507
salt-run jobs.list_job 20130916125524463507 --out=pprint
salt.runners.jobs.list_jobs(ext_source=None, outputter=None, search_metadata=None, search_function=None, search_target=None, start_time=None, end_time=None, display_progress=False)

List all detectable jobs and associated functions

ext_source

If provided, specifies which external job cache to use.

FILTER OPTIONS

Note

If more than one of the below options are used, only jobs which match all of the filters will be returned.

search_metadata

Specify a dictionary to match to the job's metadata. If any of the key-value pairs in this dictionary match, the job will be returned. Example:

salt-run jobs.list_jobs search_metadata='{"foo": "bar", "baz": "qux"}'
search_function

Can be passed as a string or a list. Returns jobs which match the specified function. Globbing is allowed. Example:

salt-run jobs.list_jobs search_function='test.*'
salt-run jobs.list_jobs search_function='["test.*", "pkg.install"]'

Changed in version 2015.8.8: Multiple targets can now also be passed as a comma-separated list. For example:

salt-run jobs.list_jobs search_function='test.*,pkg.install'
search_target

Can be passed as a string or a list. Returns jobs which match the specified minion name. Globbing is allowed. Example:

salt-run jobs.list_jobs search_target='*.mydomain.tld'
salt-run jobs.list_jobs search_target='["db*", "myminion"]'

Changed in version 2015.8.8: Multiple targets can now also be passed as a comma-separated list. For example:

salt-run jobs.list_jobs search_target='db*,myminion'
start_time

Accepts any timestamp supported by the dateutil Python module (if this module is not installed, this argument will be ignored). Returns jobs which started after this timestamp.

end_time

Accepts any timestamp supported by the dateutil Python module (if this module is not installed, this argument will be ignored). Returns jobs which started before this timestamp.

CLI Example:

salt-run jobs.list_jobs
salt-run jobs.list_jobs search_function='test.*' search_target='localhost' search_metadata='{"bar": "foo"}'
salt-run jobs.list_jobs start_time='2015, Mar 16 19:00' end_time='2015, Mar 18 22:00'
salt.runners.jobs.list_jobs_filter(count, filter_find_job=True, ext_source=None, outputter=None, display_progress=False)

List all detectable jobs and associated functions

ext_source

The external job cache to use. Default: None.

CLI Example:

salt-run jobs.list_jobs_filter 50
salt-run jobs.list_jobs_filter 100 filter_find_job=False
salt.runners.jobs.lookup_jid(jid, ext_source=None, returned=True, missing=False, display_progress=False)

Return the printout from a previously executed job

jid

The jid to look up.

ext_source

The external job cache to use. Default: None.

returnedTrue

If True, include the minions that did return from the command.

New in version 2015.8.0.

missingFalse

If True, include the minions that did not return from the command.

display_progressFalse

If True, fire progress events.

New in version 2015.5.0.

CLI Example:

salt-run jobs.lookup_jid 20130916125524463507
salt-run jobs.lookup_jid 20130916125524463507 --out=highstate
salt.runners.jobs.master()

Return the actively executing runners for the master

CLI Example:

salt-run jobs.master
salt.runners.jobs.print_job(jid, ext_source=None)

Print a specific job's detail given by its jid, including the return data.

CLI Example:

salt-run jobs.print_job 20130916125524463507