#NEWLINE# def mkconf( self , idx ) : #NEWLINE# #INDENT# '\n        Create a config file for a single minion\n        ' #NEWLINE# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if self . opts [ 'config_dir' ] : #NEWLINE# #INDENT# spath = os . path . join ( self . opts [ 'config_dir' ] , 'minion' ) #NEWLINE# with open ( spath ) as conf : #NEWLINE# #INDENT# data = yaml . load ( conf ) #NEWLINE# #UNINDENT# #UNINDENT# minion_id = '{0}-{1}' . format ( self . opts [ 'name' ] , str ( idx ) . zfill ( self . zfill ) ) #NEWLINE# dpath = os . path . join ( self . swarm_root , minion_id ) #NEWLINE# os . makedirs ( dpath ) #NEWLINE# data . update ( { #NEWLINE# #INDENT# 'id' : minion_id , #NEWLINE# 'user' : self . opts [ 'user' ] , #NEWLINE# 'cachedir' : os . path . join ( dpath , 'cache' ) , #NEWLINE# 'master' : self . opts [ 'master' ] , #NEWLINE# 'log_file' : os . path . join ( dpath , 'minion.log' ) , #NEWLINE# 'grains' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( self . opts [ 'transport' ] == 'zeromq' ) : #NEWLINE# #INDENT# minion_pkidir = os . path . join ( dpath , 'pki' ) #NEWLINE# os . makedirs ( minion_pkidir ) #NEWLINE# minion_pem = os . path . join ( self . pki , 'minion.pem' ) #NEWLINE# minion_pub = os . path . join ( self . pki , 'minion.pub' ) #NEWLINE# shutil . copy ( minion_pem , minion_pkidir ) #NEWLINE# shutil . copy ( minion_pub , minion_pkidir ) #NEWLINE# data [ 'pki_dir' ] = fn_ #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . opts [ 'transport' ] == 'raet' ) : #NEWLINE# #INDENT# data [ 'transport' ] = 'raet' #NEWLINE# data [ 'sock_dir' ] = os . path . join ( dpath , 'sock' ) #NEWLINE# data [ 'raet_port' ] = self . raet_port #NEWLINE# data [ 'pki_dir' ] = os . path . join ( dpath , 'pki' ) #NEWLINE# self . raet_port += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . opts [ 'transport' ] == 'tcp' ) : #NEWLINE# #INDENT# data [ 'transport' ] = 'tcp' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . opts [ 'root_dir' ] : #NEWLINE# #INDENT# data [ 'root_dir' ] = self . opts [ 'root_dir' ] #NEWLINE# #UNINDENT# path = os . path . join ( dpath , 'minion' ) #NEWLINE# if self . opts [ 'keep' ] : #NEWLINE# #INDENT# keep = self . opts [ 'keep' ] . split ( ',' ) #NEWLINE# modpath = os . path . join ( os . path . dirname ( salt . __file__ ) , 'modules' ) #NEWLINE# fn_prefixes = ( fn_ . partition ( '.' ) [ 0 ] for fn_ in os . listdir ( modpath ) ) #NEWLINE# ignore = [ fn_prefix for fn_prefix in fn_prefixes if ( fn_prefix not in keep ) ] #NEWLINE# data [ 'disable_modules' ] = ignore #NEWLINE# #UNINDENT# if self . opts [ 'rand_os' ] : #NEWLINE# #INDENT# data [ 'grains' ] [ 'os' ] = random . choice ( OSES ) #NEWLINE# #UNINDENT# if self . opts [ 'rand_ver' ] : #NEWLINE# #INDENT# data [ 'grains' ] [ 'saltversion' ] = random . choice ( VERS ) #NEWLINE# #UNINDENT# with open ( path , 'w+' ) as fp_ : #NEWLINE# #INDENT# yaml . dump ( data , fp_ ) #NEWLINE# #UNINDENT# self . confs . add ( dpath )