saltboot

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIGNED SignatureMethod = iota
	OPEN
	SIGNATURE      = "signature"
	SIGNED_CONTENT = "signed"
)
View Source
const (
	MinionKey    = "/etc/salt/pki/minion/minion.pem"
	SaltLocation = "/opt/"
)
View Source
const (
	START_ACTION   = "start"
	STOP_ACTION    = "stop"
	RESTART_ACTION = "restart"
)
View Source
const (
	SALT_USER               = "saltuser"
	SHADOW_FILE             = "/etc/shadow"
	SHADOW_FILE_BACKUP      = "/etc/shadow.backup"
	SHADOW_FILE_NEW         = "/etc/shadow.new"
	SHADOW_FILE_PERMISSIONS = 0640
)
View Source
const (
	UBUNTU        = "Ubuntu"
	DEBIAN        = "Debian"
	SUSE          = "SUSE"
	SLES12        = "sles12"
	AMAZONLINUX_2 = "amazonlinux2"
	AZURE         = "AZURE"
)
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"
	SaltMinionRunEP            = SaltMinionEp + "/run"
	SaltMinionStopEP           = SaltMinionEp + "/stop"
	SaltMinionKeyEP            = SaltMinionEp + "/fingerprint"
	SaltMinionKeyDistributeEP  = SaltMinionEp + "/fingerprint/distribute"
	SaltServerEp               = RootPath + "/salt/server"
	SaltServerRunEP            = SaltServerEp + "/run"
	SaltServerStopEP           = SaltServerEp + "/stop"
	SaltServerChangePasswordEP = SaltServerEp + "/change-password"
	SaltPillarEP               = RootPath + "/salt/server/pillar"
	SaltPillarDistributeEP     = RootPath + "/salt/server/pillar/distribute"
	HostnameDistributeEP       = RootPath + "/hostname/distribute"
	HostnameEP                 = RootPath + "/hostname"
	UploadEP                   = RootPath + "/file"
	FileDistributeEP           = UploadEP + "/distribute"
)
View Source
const EXAMPLE_DOMAIN = ".example.com"
View Source
const HOSTNAME_FILE = "/etc/hostname"
View Source
const HOSTS_FILE = "/etc/hosts"
View Source
const NETWORK_SYSCONFIG_FILE = "/etc/sysconfig/network"
View Source
const NETWORK_SYSCONFIG_FILE_SUSE = "/etc/sysconfig/network/config"

Variables

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

Functions

func ChangeUserPassword added in v0.13.6

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

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, os *Os) (resp model.Response, err error)

func DetermineBootstrapPort

func DetermineBootstrapPort() int

func DistributeFileUploadRequest added in v0.11.0

func DistributeFileUploadRequest(endpoint string, user string, pass string, targets []string, path string,
	permissions string, file multipart.File, header *multipart.FileHeader, signature string) <-chan model.Response

func DistributeRequest added in v0.11.0

func DistributeRequest(clients []string, endpoint, user, pass string, requestBody RequestBody) <-chan model.Response

func ExecCmd

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

func FileUploadDistributeHandler added in v0.11.0

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

func FileUploadHandler

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

func GetAuthUserPass

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

func HealthCheckHandler

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

func IsServiceRunning added in v0.11.1

func IsServiceRunning(service string) (bool, string)

func LaunchService

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

func NewCloudbreakBootstrapWeb

func NewCloudbreakBootstrapWeb()

func RestartService added in v0.11.1

func RestartService(service string) (model.Response, error)

func SaltActionDistributeRequestHandler

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

func SaltMinionKeyDistributionHandler added in v0.13.2

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

func SaltMinionKeyHandler added in v0.13.2

func SaltMinionKeyHandler(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 SaltPillarDistributeRequestHandler added in v0.11.0

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

func SaltPillarRequestHandler

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

func SaltServerChangePasswordHandler added in v0.13.6

func SaltServerChangePasswordHandler(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, serviceAction string) (resp model.Response, err error)

func StopService

func StopService(service string) (model.Response, 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 Cloud added in v0.13.0

type Cloud struct {
	Name string
}

type Fingerprint added in v0.13.2

type Fingerprint struct {
	Fingerprint *string `json:"fingerprint"`
	ErrorText   *string `json:"errorText"`
	StatusCode  int     `json:"statusCode"`
	Address     string  `json:"address"`
}

func EncodeJson added in v0.13.2

func EncodeJson(k Fingerprint, w http.ResponseWriter) Fingerprint

func (Fingerprint) String added in v0.13.2

func (r Fingerprint) String() string

func (Fingerprint) WriteHttp added in v0.13.2

func (k Fingerprint) WriteHttp(w http.ResponseWriter) Fingerprint

type FingerprintsRequest added in v0.13.2

type FingerprintsRequest struct {
	Minions []SaltMinion `json:"minions,omitempty"`
}

type FingerprintsResponse added in v0.13.2

type FingerprintsResponse struct {
	Fingerprints []Fingerprint `json:"fingerprints"`
	ErrorText    *string       `json:"errorText"`
	StatusCode   int           `json:"statusCode"`
}

func EncodeResponseJson added in v0.13.2

func (FingerprintsResponse) String added in v0.13.2

func (r FingerprintsResponse) String() string

func (FingerprintsResponse) WriteBadRequestHttp added in v0.13.2

func (r FingerprintsResponse) WriteBadRequestHttp(w http.ResponseWriter, err error) FingerprintsResponse

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
	Restart         string
	Enable          string
	Disable         string
	ActionBin       string
	StateBin        string
	CommandOrderASC bool
}

func GetInitSystem

func GetInitSystem() (system InitSystem)

func (InitSystem) ActionCommand

func (system InitSystem) ActionCommand(service string, action string) []string

func (InitSystem) Error

func (system InitSystem) Error() string

func (InitSystem) StateCommand

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

type Os added in v0.13.0

type Os struct {
	Name string
}

type RequestBody added in v0.13.2

type RequestBody struct {
	// plain request body
	PlainPayload []byte

	// signature key
	Signature string

	// request body signed with Signature
	SignedPayload string
}

func GetSignedRequestBody added in v0.13.2

func GetSignedRequestBody(r *http.Request) RequestBody

type SaltActionRequest

type SaltActionRequest struct {
	Master  SaltMaster   `json:"master,omitempty"`
	Masters []SaltMaster `json:"masters,omitempty"`
	Minions []SaltMinion `json:"minions,omitempty"`
	Action  string       `json:"action"`
	Cloud   *Cloud       `json:"cloud"`
	OS      *Os          `json:"os"`
}

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"`
	Hostname *string  `json:"hostName,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"`
	Servers       []string `json:"servers,omitempty"`
	HostGroup     string   `json:"hostGroup,omitempty"`
	Hostname      *string  `json:"hostName,omitempty"`
	Domain        string   `json:"domain,omitempty"`
	RestartNeeded *bool    `json:"restartNeeded,omitempty"`
}

func (SaltMinion) AsByteArray

func (saltMinion SaltMinion) AsByteArray() []byte

func (SaltMinion) IsRestartNeeded added in v0.13.4

func (saltMinion SaltMinion) IsRestartNeeded() bool

type SaltPillar

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

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