mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Minion-specific etcd values
This allows you to specify something such as the following in your master config to get minion-specific values in etcd that may override shared values. local_etcd: host: 127.0.0.1 port: 4001 ext_pillar: - etcd: local_etcd root=/salt-shared - etcd: local_etcd root=/salt-private/%(minion_id)s
This commit is contained in:
parent
9c43e634b6
commit
470bce8927
@ -40,7 +40,7 @@ import logging
|
||||
|
||||
# Import third party libs
|
||||
try:
|
||||
import salt.utils.etcd_util
|
||||
from salt.utils import etcd_util
|
||||
HAS_LIBS = True
|
||||
except Exception:
|
||||
HAS_LIBS = False
|
||||
@ -67,10 +67,21 @@ def ext_pillar(minion_id, pillar, conf): # pylint: disable=W0613
|
||||
profile = None
|
||||
if comps[0]:
|
||||
profile = comps[0]
|
||||
client = salt.utils.etcd_util.get_conn(__opts__, profile)
|
||||
client = etcd_util.get_conn(__opts__, profile)
|
||||
|
||||
path = '/'
|
||||
if len(comps) > 1 and comps[1].startswith('root='):
|
||||
path = comps[1].replace('root=', '')
|
||||
|
||||
return salt.utils.etcd_util.tree(client, path)
|
||||
# put the minion's ID in the path if necessary
|
||||
path %= {
|
||||
'minion_id': minion_id
|
||||
}
|
||||
|
||||
try:
|
||||
pillar = etcd_util.tree(client, path)
|
||||
except KeyError:
|
||||
log.error('No such key in etcd profile %s: %s' % (profile, path))
|
||||
pillar = {}
|
||||
|
||||
return pillar
|
||||
|
Loading…
Reference in New Issue
Block a user