Add the capability to run states when the minion starts

This commit is contained in:
Thomas S Hatch 2012-09-20 11:45:03 -06:00
parent e66ebc7621
commit 0b9fe9c8d9

View File

@ -424,6 +424,23 @@ class Minion(object):
open(fn_, 'w+').write(self.serial.dumps(ret)) open(fn_, 'w+').write(self.serial.dumps(ret))
return ret_val 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 @property
def master_pub(self): def master_pub(self):
return 'tcp://{ip}:{port}'.format(ip=self.opts['master_ip'], return 'tcp://{ip}:{port}'.format(ip=self.opts['master_ip'],
@ -544,6 +561,9 @@ class Minion(object):
# Make sure to gracefully handle SIGUSR1 # Make sure to gracefully handle SIGUSR1
enable_sigusr1_handler() enable_sigusr1_handler()
# On first startup execute a state run if configured to do so
self._state_run()
if self.opts['sub_timeout']: if self.opts['sub_timeout']:
last = time.time() last = time.time()
while True: while True: