mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Introduce ip:port minion config
This commit is contained in:
parent
a880fbcd96
commit
cb051201cf
@ -73,6 +73,11 @@ VALID_OPTS = {
|
||||
# module function to run to determine the master hostname.
|
||||
'master_type': str,
|
||||
|
||||
# Specify the format in which the master address will be specified. Can
|
||||
# specify 'default' or 'ip_only'. If 'ip_only' is specified, then the
|
||||
# master address will not be split into IP and PORT.
|
||||
'master_uri_format': str,
|
||||
|
||||
# The fingerprint of the master key may be specified to increase security. Generate
|
||||
# a master fingerprint with `salt-key -F master`
|
||||
'master_finger': str,
|
||||
@ -686,6 +691,7 @@ DEFAULT_MINION_OPTS = {
|
||||
'interface': '0.0.0.0',
|
||||
'master': 'salt',
|
||||
'master_type': 'str',
|
||||
'master_uri_format': 'default',
|
||||
'master_port': '4506',
|
||||
'master_finger': '',
|
||||
'master_shuffle': False,
|
||||
|
@ -178,6 +178,24 @@ def resolve_dns(opts):
|
||||
return ret
|
||||
|
||||
|
||||
def prep_ip_port(opts):
|
||||
ret = {}
|
||||
if opts['master_uri_format'] == 'ip_only':
|
||||
ret['master'] = opts['master']
|
||||
else:
|
||||
ip_port = opts['master'].rsplit(":", 1)
|
||||
if len(ip_port) == 1:
|
||||
# e.g. master: mysaltmaster
|
||||
ret['master'] = ip_port[0]
|
||||
else:
|
||||
# e.g. master: localhost:1234
|
||||
# e.g. master: 127.0.0.1:1234
|
||||
# e.g. master: ::1:1234
|
||||
ret['master'] = ip_port[0]
|
||||
ret['master_port'] = ip_port[1]
|
||||
return ret
|
||||
|
||||
|
||||
def get_proc_dir(cachedir, **kwargs):
|
||||
'''
|
||||
Given the cache directory, return the directory that process data is
|
||||
@ -759,6 +777,7 @@ class Minion(MinionBase):
|
||||
|
||||
for master in local_masters:
|
||||
opts['master'] = master
|
||||
opts.update(prep_ip_port(opts))
|
||||
opts.update(resolve_dns(opts))
|
||||
super(Minion, self).__init__(opts) # TODO: only run init once?? This will run once per attempt
|
||||
|
||||
@ -793,6 +812,7 @@ class Minion(MinionBase):
|
||||
|
||||
# single master sign in
|
||||
else:
|
||||
opts.update(prep_ip_port(opts))
|
||||
opts.update(resolve_dns(opts))
|
||||
pub_channel = salt.transport.client.AsyncPubChannel.factory(self.opts,
|
||||
timeout=timeout,
|
||||
|
Loading…
Reference in New Issue
Block a user