mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Add the capability to run states when the minion starts
This commit is contained in:
parent
e66ebc7621
commit
0b9fe9c8d9
@ -424,6 +424,23 @@ class Minion(object):
|
||||
open(fn_, 'w+').write(self.serial.dumps(ret))
|
||||
return ret_val
|
||||
|
||||
def _state_run(self):
|
||||
'''
|
||||
Execute a state run based on information set in the minion config file
|
||||
'''
|
||||
if self.opts['startup_states']:
|
||||
data = {'jid': 'req', 'ret': ''}
|
||||
if self.opts['startup_states'] == 'sls':
|
||||
data['fun'] = 'state.sls'
|
||||
data['arg'] = [self.opts['sls_list']]
|
||||
elif self.opts['startup_states'] == 'top':
|
||||
data['fun'] = 'state.top'
|
||||
data['arg'] = [self.opts['top_file']]
|
||||
else:
|
||||
data['fun'] = 'state.highstate'
|
||||
data['arg'] = []
|
||||
self._handle_decoded_payload(data)
|
||||
|
||||
@property
|
||||
def master_pub(self):
|
||||
return 'tcp://{ip}:{port}'.format(ip=self.opts['master_ip'],
|
||||
@ -544,6 +561,9 @@ class Minion(object):
|
||||
# Make sure to gracefully handle SIGUSR1
|
||||
enable_sigusr1_handler()
|
||||
|
||||
# On first startup execute a state run if configured to do so
|
||||
self._state_run()
|
||||
|
||||
if self.opts['sub_timeout']:
|
||||
last = time.time()
|
||||
while True:
|
||||
|
Loading…
Reference in New Issue
Block a user