salt.pillar.etcd_pillar#

Use etcd data as a Pillar source

New in version 2014.7.0.

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.

depends:
  • etcd3gw

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

my_etcd_config:
  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.

Values are read msgpack-decoded unless the profile sets etcd.encode_values: False. Set it when the values are written by other tools, such as etcdctl, rather than by Salt.

After the profile is created, configure the external pillar system to use it. Optionally, a root may be specified.

ext_pillar:
  - etcd: my_etcd_config

ext_pillar:
  - etcd: my_etcd_config root=/salt

The pillar data is the tree of keys under the root, split on /. Only the root key and the keys under <root>/ are read, so root=/salt does not pick up /saltstack. A root with no keys under it adds no pillar data. An error talking to etcd fails the pillar render instead of returning empty pillar data.

Using these configuration profiles, multiple etcd sources may also be used:

ext_pillar:
  - etcd: my_etcd_config
  - etcd: my_other_etcd_config

The minion_id may be used in the root path to expose minion-specific information stored in etcd.

ext_pillar:
  - etcd: my_etcd_config root=/salt/%(minion_id)s

Minion-specific values may override shared values when the minion-specific root appears after the shared root:

ext_pillar:
  - etcd: my_etcd_config root=/salt-shared
  - etcd: my_other_etcd_config root=/salt-private/%(minion_id)s

Using the configuration above, with etcd.encode_values: False in both profiles, the following commands could be used to share a key with all minions but override its value for a specific minion:

etcdctl put /salt-shared/mykey my_value
etcdctl put /salt-private/special_minion_id/mykey my_other_value
salt.pillar.etcd_pillar.ext_pillar(minion_id, pillar, conf)#

Check etcd for all data