saltboot

package
v0.10.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2017 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIGNED SignatureMethod = iota
	OPEN
	SIGNATURE      = "signature"
	SIGNED_CONTENT = "signed"
)
View Source
const (
	ENV_TYPE          = "SALT_BOOTSTRAP_ENV_TYPE"
	EXECUTED_COMMANDS = "EXECUTED_COMMANDS"
)
View Source
const (
	RootPath               = "/saltboot"
	HealthEP               = RootPath + "/health"
	ServerSaveEP           = RootPath + "/server/save"
	ServerDistributeEP     = RootPath + "/server/distribute"
	SaltActionDistributeEP = RootPath + "/salt/action/distribute"
	SaltMinionEp           = RootPath + "/salt/minion"
	SaltServerEp           = RootPath + "/salt/server"
	SaltMinionRunEP        = SaltMinionEp + "/run"
	SaltMinionStopEP       = SaltMinionEp + "/stop"
	SaltServerRunEP        = SaltServerEp + "/run"
	SaltServerStopEP       = SaltServerEp + "/stop"
	SaltPillarEP           = RootPath + "/salt/server/pillar"
	HostnameDistributeEP   = RootPath + "/hostname/distribute"
	HostnameEP             = RootPath + "/hostname"
	UploadEP               = RootPath + "/file"
)
View Source
const DEFAULT_DOMAIN = ".example.com"
View Source
const HOST_FILE_NAME = "/etc/hosts"
View Source
const SALT_USER = "saltuser"

Variables

View Source
var (
	SYSYEM_D   = InitSystem{ActionBin: "/bin/systemctl", StateBin: "/bin/systemctl", Start: "start", Stop: "stop", Enable: "enable", Disable: "disable", CommandOrderASC: true}
	SYS_V_INIT = InitSystem{ActionBin: "/sbin/service", StateBin: "/sbin/chkconfig", Start: "start", Stop: "stop", Enable: "on", Disable: "off", CommandOrderASC: false}
)
View Source
var (
	Version   string
	BuildTime string
)

Functions

func CheckAuth

func CheckAuth(user string, pass string, r *http.Request) bool

func CheckSignature

func CheckSignature(rawSign string, pubPem []byte, data []byte) bool

func ClientDistributionHandler

func ClientDistributionHandler(w http.ResponseWriter, req *http.Request)

func ClientHostnameDistributionHandler

func ClientHostnameDistributionHandler(w http.ResponseWriter, req *http.Request)

func ClientHostnameHandler

func ClientHostnameHandler(w http.ResponseWriter, req *http.Request)

func CreateUser

func CreateUser(saltMaster SaltMaster) (resp model.Response, err error)

func DetermineBootstrapPort

func DetermineBootstrapPort() int

func Distribute

func Distribute(clients []string, payload []byte, endpoint string, user string, pass string) <-chan model.Response

func DistributeActionRequest added in v0.10.2

func DistributeActionRequest(clients []string, request SaltActionRequest, endpoint string, user string, pass string, signature string, signed string) <-chan model.Response

func ExecCmd

func ExecCmd(executable string, args ...string) (outStr string, err error)

func FileUploadHandler

func FileUploadHandler(w http.ResponseWriter, req *http.Request)

func GetAuthUserPass

func GetAuthUserPass(r *http.Request) (string, string)

func GetSignatureAndSigned added in v0.10.2

func GetSignatureAndSigned(r *http.Request) (string, string)

func HealthCheckHandler

func HealthCheckHandler(w http.ResponseWriter, req *http.Request)

func LaunchService

func LaunchService(service string) (resp model.Response, err error)

func NewCloudbreakBootstrapWeb

func NewCloudbreakBootstrapWeb()

func SaltActionDistributeRequestHandler

func SaltActionDistributeRequestHandler(w http.ResponseWriter, req *http.Request)

func SaltMinionRunRequestHandler

func SaltMinionRunRequestHandler(w http.ResponseWriter, req *http.Request)

func SaltMinionStopRequestHandler

func SaltMinionStopRequestHandler(w http.ResponseWriter, req *http.Request)

func SaltPillarRequestHandler

func SaltPillarRequestHandler(w http.ResponseWriter, req *http.Request)

func SaltServerRunRequestHandler

func SaltServerRunRequestHandler(w http.ResponseWriter, req *http.Request)

func SaltServerStopRequestHandler

func SaltServerStopRequestHandler(w http.ResponseWriter, req *http.Request)

func ServerRequestHandler

func ServerRequestHandler(w http.ResponseWriter, req *http.Request)

func SetServiceState

func SetServiceState(service string, up bool) (resp model.Response, err error)

func StopService

func StopService(service string) (resp model.Response, err error)

func Unzip

func Unzip(src, dest string) error

Types

type Authenticator

type Authenticator struct {
	Username     string
	Password     string
	SignatureKey []byte
}

func (*Authenticator) Wrap

func (a *Authenticator) Wrap(handler func(w http.ResponseWriter, req *http.Request), signatureMethod SignatureMethod) http.Handler

type Clients

type Clients struct {
	Clients []string `json:"clients,omitempty"`
	Servers []Server `json:"servers,omitempty"`
	Path    string   `json:"path"`
}

func (*Clients) DistributeAddress

func (clients *Clients) DistributeAddress(user string, pass string) (result []model.Response)

func (*Clients) DistributeHostnameRequest

func (clients *Clients) DistributeHostnameRequest(user string, pass string) (result []model.Response)

type GrainConfig

type GrainConfig struct {
	HostGroup string   `json:"hostgroup" yaml:"hostgroup"`
	Roles     []string `json:"roles" yaml:"roles"`
}

type InitSystem

type InitSystem struct {
	Start           string
	Stop            string
	Enable          string
	Disable         string
	ActionBin       string
	StateBin        string
	CommandOrderASC bool
}

func GetInitSystem

func GetInitSystem(stat func(name string) (os.FileInfo, error)) (system InitSystem)

func (InitSystem) ActionCommand

func (system InitSystem) ActionCommand(service string, run bool) []string

func (InitSystem) Error

func (system InitSystem) Error() string

func (InitSystem) StateCommand

func (system InitSystem) StateCommand(service string, enable bool) []string

type SaltActionRequest

type SaltActionRequest struct {
	Master  SaltMaster   `json:"master,omitempty"`
	Minions []SaltMinion `json:"minions,omitempty"`
	Action  string       `json:"action"`
}

func (SaltActionRequest) String

func (r SaltActionRequest) String() string

type SaltAuth

type SaltAuth struct {
	Password string `json:"password,omitempty"`
}

type SaltMaster

type SaltMaster struct {
	Address string   `json:"address"`
	Auth    SaltAuth `json:"auth,omitempty"`
	Domain  string   `json:"domain,omitempty"`
}

func (SaltMaster) AsByteArray

func (saltMaster SaltMaster) AsByteArray() []byte

type SaltMinion

type SaltMinion struct {
	Address   string   `json:"address"`
	Roles     []string `json:"roles,omitempty"`
	Server    string   `json:"server,omitempty"`
	HostGroup string   `json:"hostGroup,omitempty"`
	Domain    string   `json:"domain,omitempty"`
}

func (SaltMinion) AsByteArray

func (saltMinion SaltMinion) AsByteArray() []byte

type SaltPillar

type SaltPillar struct {
	Path string                 `json:"path"`
	Json map[string]interface{} `json:"json"`
}

func (SaltPillar) WritePillar

func (pillar SaltPillar) WritePillar() (outStr string, err error)

type SecurityConfig

type SecurityConfig struct {
	Username      string `json:"username" yaml:"username"`
	Password      string `json:"password" yaml:"password"`
	SignVerifyKey string `json:"signKey" yaml:"signKey"`
}

func DetermineSecurityDetails

func DetermineSecurityDetails(getEnv func(key string) string, securityConfig func() string) (*SecurityConfig, error)

type Server

type Server struct {
	Name    string `json:"name"`
	Address string `json:"address"`
}

func (Server) String

func (r Server) String() string

type Servers

type Servers struct {
	Servers []Server `json:"servers"`
	Path    string   `  json:"path"`
}

func (*Servers) WriteToFile

func (s *Servers) WriteToFile() (outStr string, err error)

type SignatureMethod

type SignatureMethod int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL