// runNodesProvisionHook runs nodes provisioning hook defined by user
// application manifest
runNodesProvisionHook runs nodes provisioning hook defined by user
application manifest
// runNodesProvisionHook runs nodes provisioning hook defined by user // application manifest
func (s *site) runNodesProvisionHook(ctx *operationContext) error {
	s.reportProgress(ctx, ops.ProgressEntry{
		State:      ops.ProgressStateInProgress,
		Completion: 5,
		Message:    "Running nodes provisioning hook",
	})
	vars := ctx.operation.InstallExpand.Vars
	env := map[string]string{
		constants.EnvTelekubeClusterName: vars.System.ClusterName,
		constants.EnvTelekubeOpsURL:      vars.System.OpsURL,
	}
	if vars.System.Devmode {
		env[constants.EnvTelekubeDevMode] = fmt.Sprintf("%v", vars.System.Devmode)
	}
	site, err := s.service.GetSite(s.key)
	if err != nil {
		return trace.Wrap(err)
	}
	job, err := s.app.Manifest.Hooks.NodesProvision.GetJob()
	if err != nil {
		return trace.Wrap(err)
	}
	existingServers := site.ClusterState.ProfileMap()
	var profiles []string
	for profileName, profile := range ctx.profiles() {
		profiles = append(profiles, profileName)
		env[fmt.Sprintf(constants.EnvTelekubeNodeProfileAddCountTemplate, profileName)] = fmt.Sprintf("%v", profile.Request.Count)
		env[fmt.Sprintf(constants.EnvTelekubeNodeProfileCountTemplate, profileName)] = fmt.Sprintf("%v", profile.Request.Count+len(existingServers[profileName]))
		env[fmt.Sprintf(constants.EnvTelekubeNodeProfileInstanceTypeTemplate, profileName)] = fmt.Sprintf("%v", profile.Request.InstanceType)
	}
	env[constants.EnvTelekubeNodeProfiles] = strings.Join(profiles, ",")
	request := app.HookRunRequest{
		Application: s.app.Package,
		Hook:        schema.HookNodesProvision,
		Env:         env,
	}
	secretParams := secretParams{
		token: vars.System.Token,
	}
	switch provider := s.cloudProvider().(type) {
	case *aws:
		env[constants.EnvCloudProvider] = schema.ProviderAWS
		env[constants.EnvAWSAMI] = vars.AWS.AMI
		env[constants.EnvAWSRegion] = vars.AWS.Region
		env[constants.EnvAWSVPCID] = vars.AWS.VPCID
		env[constants.EnvAWSKeyName] = vars.AWS.KeyPair
		secretParams.aws = &awsSecrets{
			accessKeyID:     provider.accessKey,
			secretAccessKey: provider.secretKey,
			sessionToken:    provider.sessionToken,
		}
	}
	return s.runIntegrationHook(ctx, job, request, secretParams)
}
func ( s * site ) runNodesProvisionHook ( ctx * operationContext ) error { s . reportProgress ( ctx , ops . ProgressEntry { State : ops . ProgressStateInProgress , Completion : 5 , Message : " " , } ) vars := ctx . operation . InstallExpand . Vars env := map [ string ] string { constants . EnvTelekubeClusterName : vars . System . ClusterName , constants . EnvTelekubeOpsURL : vars . System . OpsURL , } if vars . System . Devmode { env [ constants . EnvTelekubeDevMode ] = fmt . Sprintf ( " " , vars . System . Devmode ) } site , err := s . service . GetSite ( s . key ) if err != nil { return trace . Wrap ( err ) } job , err := s . app . Manifest . Hooks . NodesProvision . GetJob ( ) if err != nil { return trace . Wrap ( err ) } existingServers := site . ClusterState . ProfileMap ( ) var profiles [ ] string for profileName , profile := range ctx . profiles ( ) { profiles = append ( profiles , profileName ) env [ fmt . Sprintf ( constants . EnvTelekubeNodeProfileAddCountTemplate , profileName ) ] = fmt . Sprintf ( " " , profile . Request . Count ) env [ fmt . Sprintf ( constants . EnvTelekubeNodeProfileCountTemplate , profileName ) ] = fmt . Sprintf ( " " , profile . Request . Count + len ( existingServers [ profileName ] ) ) env [ fmt . Sprintf ( constants . EnvTelekubeNodeProfileInstanceTypeTemplate , profileName ) ] = fmt . Sprintf ( " " , profile . Request . InstanceType ) } env [ constants . EnvTelekubeNodeProfiles ] = strings . Join ( profiles , " " ) request := app . HookRunRequest { Application : s . app . Package , Hook : schema . HookNodesProvision , Env : env , } secretParams := secretParams { token : vars . System . Token , } switch provider := s . cloudProvider ( ) . ( type ) { case * aws : env [ constants . EnvCloudProvider ] = schema . ProviderAWS env [ constants . EnvAWSAMI ] = vars . AWS . AMI env [ constants . EnvAWSRegion ] = vars . AWS . Region env [ constants . EnvAWSVPCID ] = vars . AWS . VPCID env [ constants . EnvAWSKeyName ] = vars . AWS . KeyPair secretParams . aws = & awsSecrets { accessKeyID : provider . accessKey , secretAccessKey : provider . secretKey , sessionToken : provider . sessionToken , } } return s . runIntegrationHook ( ctx , job , request , secretParams ) }
runNodesProvisionHook runs nodes provisioning hook defined by user
application manifest
runNodesProvisionHook runs nodes provisioning hook defined by user application manifest
// these are common environment variables valid for all provisioners // set profiles and roles // count of servers to be added // total desired count of the servers // set up common parameters // setup parameters for VPC