def start(self): ''' Run the sequence to start a salt master server ''' verify_env([ os.path.join(self.opts['pki_dir'], 'minions'), os.path.join(self.opts['pki_dir'], 'minions_pre'), os.path.join(self.opts['pki_dir'], 'minions_rejected'), os.path.join(self.opts['cachedir'], 'jobs'), os.path.dirname(self.opts['log_file']), self.opts['sock_dir'], ]) import salt.log salt.log.setup_logfile_logger(self.opts['log_file'], self.opts['log_level']) for name, level in self.opts['log_granular_levels'].iteritems(): salt.log.set_logger_level(name, level) import logging log = logging.getLogger(__name__) # Late import so logging works correctly import salt.master master = salt.master.Master(self.opts) if self.cli['daemon']: # Late import so logging works correctly import salt.utils salt.utils.daemonize() set_pidfile(self.opts['pidfile']) if check_user(self.opts['user'], log): try: master.start() except salt.master.MasterExit: sys.exit()
def start(self): ''' Run the sequence to start a salt master server ''' verify_env([os.path.join(self.opts['pki_dir'], 'minions'), os.path.join(self.opts['pki_dir'], 'minions_pre'), os.path.join(self.opts['pki_dir'], 'minions_rejected'), os.path.join(self.opts['cachedir'], 'jobs'), os.path.dirname(self.opts['log_file']), self.opts['sock_dir'], ]) import salt.log salt.log.setup_logfile_logger( self.opts['log_file'], self.opts['log_level'] ) for name, level in self.opts['log_granular_levels'].iteritems(): salt.log.set_logger_level(name, level) import logging log = logging.getLogger(__name__) # Late import so logging works correctly if check_user(self.opts['user'], log): import salt.master master = salt.master.Master(self.opts) if self.cli['daemon']: # Late import so logging works correctly import salt.utils salt.utils.daemonize() set_pidfile(self.cli['pidfile']) master.start()
def start(self): ''' Run the sequence to start a salt master server ''' verify_env([ os.path.join(self.opts['pki_dir'], 'minions'), os.path.join(self.opts['pki_dir'], 'minions_pre'), os.path.join(self.opts['cachedir'], 'jobs'), os.path.dirname(self.opts['log_file']), self.opts['sock_dir'], ]) import salt.log salt.log.setup_logfile_logger(self.opts['log_file'], self.opts['log_level']) for name, level in self.opts['log_granular_levels'].iteritems(): salt.log.set_logger_level(name, level) import logging # Late import so logging works correctly import salt.master master = salt.master.Master(self.opts) if self.cli['daemon']: # Late import so logging works correctly import salt.utils salt.utils.daemonize() master.start()
def launch_server(): """ Start the salt master here """ hostname = get_fqhostname() ip = host_to_ip(hostname) log.debug("Hellostack start server %s" % ip) master_opts = salt.config.client_config("/etc/salt/master") master = salt.master.Master(master_opts) master.start()
def start(self): ''' Run the sequence to start a salt master server ''' verify_env([os.path.join(self.opts['pki_dir'], 'minions'), os.path.join(self.opts['pki_dir'], 'minions_pre'), os.path.join(self.opts['cachedir'], 'jobs'), ]) master = salt.master.Master(self.opts) if self.cli['daemon']: salt.utils.daemonize() master.start()
def start(self): ''' Run the sequence to start a salt master server ''' verify_env([ os.path.join(self.opts['pki_dir'], 'minions'), os.path.join(self.opts['pki_dir'], 'minions_pre'), os.path.join(self.opts['cachedir'], 'jobs'), ]) master = salt.master.Master(self.opts) if self.cli['daemon']: salt.utils.daemonize() master.start()
def start(self): ''' Run the sequence to start a salt master server ''' self.parse_args() try: if self.config['verify_env']: verify_env( [ self.config['pki_dir'], os.path.join(self.config['pki_dir'], 'minions'), os.path.join(self.config['pki_dir'], 'minions_pre'), os.path.join(self.config['pki_dir'], 'minions_rejected'), self.config['cachedir'], os.path.join(self.config['cachedir'], 'jobs'), os.path.join(self.config['cachedir'], 'proc'), os.path.dirname(self.config['log_file']), self.config['sock_dir'], self.config['token_dir'], ], self.config['user'], permissive=self.config['permissive_pki_access'], pki_dir=self.config['pki_dir'], ) except OSError as err: sys.exit(err.errno) self.setup_logfile_logger() logging.getLogger(__name__).warn('Setting up the Salt Master') # Late import so logging works correctly if not verify_socket(self.config['interface'], self.config['publish_port'], self.config['ret_port']): self.exit(4, 'The ports are not available to bind\n') migrations.migrate_paths(self.config) import salt.master master = salt.master.Master(self.config) self.daemonize_if_required() self.set_pidfile() if check_user(self.config['user']): try: master.start() except salt.master.MasterExit: sys.exit()
def start(self): ''' Run the sequence to start a salt master server ''' self.parse_args() try: if self.config['verify_env']: verify_env([ self.config['pki_dir'], os.path.join(self.config['pki_dir'], 'minions'), os.path.join(self.config['pki_dir'], 'minions_pre'), os.path.join(self.config['pki_dir'], 'minions_rejected'), self.config['cachedir'], os.path.join(self.config['cachedir'], 'jobs'), os.path.join(self.config['cachedir'], 'proc'), os.path.dirname(self.config['log_file']), self.config['sock_dir'], self.config['token_dir'], ], self.config['user'], permissive=self.config['permissive_pki_access'], pki_dir=self.config['pki_dir'], ) except OSError as err: sys.exit(err.errno) self.setup_logfile_logger() logging.getLogger(__name__).warn('Setting up the Salt Master') # Late import so logging works correctly if not verify_socket(self.config['interface'], self.config['publish_port'], self.config['ret_port']): self.exit(4, 'The ports are not available to bind\n') migrations.migrate_paths(self.config) import salt.master master = salt.master.Master(self.config) self.daemonize_if_required() self.set_pidfile() if check_user(self.config['user']): try: master.start() except salt.master.MasterExit: sys.exit()
def start(self): ''' Run the sequence to start a salt master server ''' import salt.log salt.log.setup_logfile_logger( self.opts['log_file'], self.opts['log_level'] ) for name, level in self.opts['log_granular_levels'].iteritems(): salt.log.set_logger_level(name, level) import logging verify_env([os.path.join(self.opts['pki_dir'], 'minions'), os.path.join(self.opts['pki_dir'], 'minions_pre'), os.path.join(self.opts['cachedir'], 'jobs'), ]) # Late import so logging works correctly import salt.master master = salt.master.Master(self.opts) if self.cli['daemon']: # Late import so logging works correctly import salt.utils salt.utils.daemonize() master.start()
class Master(parsers.MasterOptionParser): ''' Creates a master server ''' def start(self): ''' Run the sequence to start a salt master server ''' self.parse_args() try: if self.config['verify_env']: verify_env( [ self.config['pki_dir'], os.path.join(self.config['pki_dir'], 'minions'), os.path.join(self.config['pki_dir'], 'minions_pre'), os.path.join(self.config['pki_dir'], 'minions_rejected'), self.config['cachedir'], os.path.join(self.config['cachedir'], 'jobs'), os.path.dirname(self.config['log_file']), self.config['sock_dir'], ], self.config['user'], permissive=self.config['permissive_pki_access'], pki_dir=self.config['pki_dir'], ) except OSError, err: sys.exit(err.errno) self.setup_logfile_logger() # Late import so logging works correctly if not verify_socket(self.config['interface'], self.config['publish_port'], self.config['ret_port']): self.exit(4, 'The ports are not available to bind') import salt.master master = salt.master.Master(self.config) self.daemonize_if_required() self.set_pidfile() if check_user(self.config['user']): try: master.start() except salt.master.MasterExit: sys.exit()
class Master(object): ''' Creates a master server ''' def __init__(self): self.cli = self.__parse_cli() # command line overrides config if self.cli['user']: self.opts['user'] = self.cli['user'] # Send the pidfile location to the opts if self.cli['pidfile']: self.opts['pidfile'] = self.cli['pidfile'] def __parse_cli(self): ''' Parse the cli for options passed to a master daemon ''' import salt.log parser = optparse.OptionParser(version="%%prog %s" % __version__) parser.add_option('-d', '--daemon', dest='daemon', default=False, action='store_true', help='Run the master as a daemon') parser.add_option('-c', '--config', dest='config', default='/etc/salt/master', help='Pass in an alternative configuration file') parser.add_option('-u', '--user', dest='user', help='Specify user to run master') parser.add_option('--pid-file', dest='pidfile', help=('Specify the location of the pidfile.')) parser.add_option( '-l', '--log-level', dest='log_level', choices=list(salt.log.LOG_LEVELS), help='Console log level. One of %s. For the logfile settings ' 'see the config file. Default: \'warning\'.' % ', '.join([repr(l) for l in salt.log.SORTED_LEVEL_NAMES])) options, args = parser.parse_args() self.opts = salt.config.master_config(options.config) if not options.log_level: options.log_level = self.opts['log_level'] salt.log.setup_console_logger(options.log_level, log_format=self.opts['log_fmt_console'], date_format=self.opts['log_datefmt']) cli = { 'daemon': options.daemon, 'config': options.config, 'user': options.user, 'pidfile': options.pidfile } return cli def start(self): ''' Run the sequence to start a salt master server ''' try: verify_env([ self.opts['pki_dir'], os.path.join(self.opts['pki_dir'], 'minions'), os.path.join(self.opts['pki_dir'], 'minions_pre'), os.path.join(self.opts['pki_dir'], 'minions_rejected'), self.opts['cachedir'], os.path.join(self.opts['cachedir'], 'jobs'), os.path.dirname(self.opts['log_file']), self.opts['sock_dir'], ], self.opts['user'], permissive=self.opts['permissive_pki_access']) except OSError, err: sys.exit(err.errno) import salt.log salt.log.setup_logfile_logger(self.opts['log_file'], self.opts['log_level_logfile'] or self.opts['log_level'], log_format=self.opts['log_fmt_logfile'], date_format=self.opts['log_datefmt']) for name, level in self.opts['log_granular_levels'].items(): salt.log.set_logger_level(name, level) import logging log = logging.getLogger(__name__) # Late import so logging works correctly if not verify_socket(self.opts['interface'], self.opts['publish_port'], self.opts['ret_port']): log.critical('The ports are not available to bind') sys.exit(4) import salt.master master = salt.master.Master(self.opts) if self.cli['daemon']: # Late import so logging works correctly import salt.utils salt.utils.daemonize() set_pidfile(self.opts['pidfile']) if check_user(self.opts['user'], log): try: master.start() except salt.master.MasterExit: sys.exit()