salt.returners.etcd_return#

Return data to an etcd server or cluster

Changed in version 3009.0: Restored for the etcd v3 API after its removal in 3008.0. It uses salt.utils.etcd_util, so the etcd v2 API and the etcd.require_v2 option are no longer supported. It also works as a master_job_cache now, and each minion return is stored as one key.

depends:
  • etcd3gw

In order to return to an etcd server, a profile should be created in the master configuration file:

my_etcd_config:
  etcd.host: 127.0.0.1
  etcd.port: 2379

It is technically possible to configure etcd without using a profile, but this is not considered to be a best practice, especially when multiple etcd servers or clusters are available.

etcd.host: 127.0.0.1
etcd.port: 2379

The profile takes the other etcd.* options of salt.utils.etcd_util as well, such as etcd.username/etcd.password and the TLS options.

Additionally, two more options must be specified in the top-level configuration in order to use the etcd returner:

etcd.returner: my_etcd_config
etcd.returner_root: /salt/return

The etcd.returner option specifies which configuration profile to use. The etcd.returner_root option specifies the path inside etcd to use as the root of the returner system.

Once the etcd options are configured, the returner may be used:

CLI Example:

salt '*' test.ping --return etcd

It can also be the master's job cache:

master_job_cache: etcd

You can also set a TTL (time to live) value for the returner, in seconds:

etcd.ttl: 5

Without etcd.ttl, the master's clean_old_jobs maintenance removes jobs older than keep_jobs_seconds when this returner is the master_job_cache.

You may also specify different roles for read and write operations. First, create the profiles as specified above. Then add:

etcd.returner_read_profile: my_etcd_read
etcd.returner_write_profile: my_etcd_write

With a write profile, etcd.ttl is read from that profile.

The data is stored under the root as follows:

  • minions/<minion id>: the last job ID the minion returned for

  • jobs/<jid>/<minion id>: the minion's return (return, retcode, success, out, fun, fun_args, when present)

  • jobs/<jid>/.load.p: the job's load

  • jobs/<jid>/.minions.p: the minions the job targeted

  • jobs/<jid>/.endtime.p: the job's end time, with job_cache_store_endtime

  • jobs/<jid>/.nocache.p: set when the job was started with nocache

Values are msgpack-encoded by default, which also stores binary return data. With etcd.encode_values: False they are stored as JSON instead, which cannot hold binary data.

salt.returners.etcd_return.clean_old_jobs()#

Remove jobs older than keep_jobs_seconds

salt.returners.etcd_return.get_endtime(jid)#

Return the end time of a job, or False if it was not saved

salt.returners.etcd_return.get_fun(fun)#

Return a dict of the last function called for all minions

salt.returners.etcd_return.get_jid(jid)#

Return the information returned when the specified job id was executed

salt.returners.etcd_return.get_jids()#

Return a dict mapping all job ids to job information

salt.returners.etcd_return.get_jids_filter(count, filter_find_job=True)#

Return the count most recent jobs, optionally without saltutil.find_job calls

salt.returners.etcd_return.get_load(jid)#

Return the load data that marks a specified jid, with the targeted minions under Minions

salt.returners.etcd_return.get_minions()#

Return a list of minions

salt.returners.etcd_return.prep_jid(nocache=False, passed_jid=None)#

Do any work necessary to prepare a JID, including sending a custom id

salt.returners.etcd_return.returner(ret)#

Return data to an etcd server or cluster

salt.returners.etcd_return.save_load(jid, load, minions=None)#

Save the load to the specified jid

salt.returners.etcd_return.save_minions(jid, minions, syndic_id=None)#

Save the minions targeted by a job, merged with any already saved

salt.returners.etcd_return.update_endtime(jid, time)#

Save the end time of a job