choria

package
v0.0.0-...-87ce47b Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2017 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExist

func FileExist(path string) bool

FileExist checks if a file exist on disk

func SliceGroups

func SliceGroups(input []string, size int, fn func(group []string))

SliceGroups takes a slice of words and make new chunks of given size and call the function with the sub slice. If there are not enough items in the input slice empty strings will pad the last group

func StrToBool

func StrToBool(s string) (bool, error)

StrToBool converts a typical mcollective boolianish string to bool

func UserConfig

func UserConfig() string

UserConfig determines what is the active config file for a user TODO: windows

Types

type Choria

type Choria struct {
	Config *MCollectiveConfig
}

Choria is a utilty encompasing mcollective and choria config and various utilities

func New

func New(path string) (*Choria, error)

New sets up a Choria with all its config loaded and so forth

func (*Choria) CAPath

func (c *Choria) CAPath() (string, error)

CAPath determines the path to the CA file

func (*Choria) Certname

func (c *Choria) Certname() string

Certname determines the choria certname

func (*Choria) ClientPrivateKey

func (c *Choria) ClientPrivateKey() (string, error)

ClientPrivateKey determines the location to the client cert

func (*Choria) ClientPublicCert

func (c *Choria) ClientPublicCert() (string, error)

ClientPublicCert determines the location to the client cert

func (*Choria) DiscoveryServer

func (c *Choria) DiscoveryServer() (Server, error)

DiscoveryServer is the server configured as a discovery proxy

func (*Choria) FacterCmd

func (c *Choria) FacterCmd() string

FacterCmd finds the path to facter using first AIO path then a `which` like command TODO: windows support

func (*Choria) FacterDomain

func (c *Choria) FacterDomain() (string, error)

FacterDomain determines the machines domain by querying facter. Returns "" when unknown

func (*Choria) ProxiedDiscovery

func (c *Choria) ProxiedDiscovery() bool

ProxiedDiscovery determines if a client is configured for proxied discover

func (*Choria) PuppetSetting

func (c *Choria) PuppetSetting(setting string) (string, error)

PuppetSetting retrieves a config setting by shelling out to puppet apply --configprint

func (*Choria) QuerySrvRecords

func (c *Choria) QuerySrvRecords(records []string) ([]Server, error)

QuerySrvRecords looks for SRV records within the right domain either thanks to facter domain or the configured domain.

If the config disables SRV then a error is returned.

func (*Choria) SSLContext

func (c *Choria) SSLContext() (*http.Transport, error)

SSLContext creates a SSL context loaded with our certs and ca

func (*Choria) SSLDir

func (c *Choria) SSLDir() (string, error)

SSLDir determines the AIO SSL directory

func (*Choria) TrySrvLookup

func (c *Choria) TrySrvLookup(names []string, defaultSrv Server) (Server, error)

TrySrvLookup will attempt to lookup a series of names returning the first found if SRV lookups are disabled or nothing is found the default will be returned

type ChoriaPluginConfig

type ChoriaPluginConfig struct {
	PuppetServerHost string `confkey:"plugin.choria.puppetserver_host" default:"puppet"`
	PuppetServerPort int    `confkey:"plugin.choria.puppetserver_port" default:"8140"`
	PuppetCAHost     string `confkey:"plugin.choria.puppetca_host" default:"puppet"`
	PuppetCAPort     int    `confkey:"plugin.choria.puppetca_port" default:"8140"`
	PuppetDBHost     string `confkey:"plugin.choria.puppetdb_host" default:"puppet"`
	PuppetDBPort     int    `confkey:"plugin.choria.puppetdb_port" default:"8081"`
	SSLDir           string `confkey:"plugin.choria.ssl_dir"`
	UseSRVRecords    bool   `confkey:"plugin.choria.use_srv" default:"true"`
	SRVDomain        string `confkey:"plugin.choria.srv_domain"`

	// discovery proxy
	DiscoveryHost  string `confkey:"plugin.choria.discovery_host" default:"puppet"`
	DiscoveryPort  int    `confkey:"plugin.choria.discovery_port" default:"8085"`
	DiscoveryProxy bool   `confkey:"plugin.choria.discovery_proxy" default:"false"`

	// federation
	FederationCollectives []string `confkey:"plugin.choria.federation.collectives" type:"comma_split" environment:"CHORIA_FED_COLLECTIVE"`
	StatsPort             int      `configkey:"plugin.choria.stats_port"`

	// nats connector
	NatsUser                  string   `confkey:"plugin.nats.user" environment:"MCOLLECTIVE_NATS_USERNAME"`
	NatsPass                  string   `confkey:"plugin.nats.pass" environment:"MCOLLECTIVE_NATS_PASSWORD"`
	MiddlewareHosts           []string `confkey:"plugin.choria.middleware_hosts" type:"comma_split"`
	FederationMiddlewareHosts []string `confkey:"plugin.choria.federation_middleware_hosts" type:"comma_split"`
	RandomizeMiddlewareHosts  bool     `confkey:"plugin.choria.randomize_middleware_hosts" default:"false"`

	// security plugin
	PrivilegedUsers   []string `confkey:"plugin.choria.security.privileged_users" type:"comma_split"`
	CertnameWhitelist []string `confkey:"plugin.choria.security.certname_whitelist" type:"comma_split"`
	Serializer        string   `confkey:"plugin.choria.security.serializer"` // TODO support enums
}

ChoriaPluginConfig settings

type MCollectiveConfig

type MCollectiveConfig struct {
	Registration              string   `confkey:"registration" default:"Agentlist" type:"title_string"`
	RegistrationCollective    string   `confkey:"registration_collective"`
	RegisterInterval          int      `confkey:"registerinterval" default:"0"`
	RegistrationSplay         bool     `confkey:"registration_splay" default:"false"`
	Collectives               []string `confkey:"collectives" type:"comma_split" default:"mcollective"`
	MainCollective            string   `confkey:"main_collective"`
	LogFile                   string   `confkey:"logfile"`
	KeepLogs                  int      `confkey:"keeplogs" default:"5"`
	MaxLogSize                int      `confkey:"max_log_size" default:"2097152"`
	LogLevel                  string   `confkey:"loglevel" default:"info"` // TODO support enums
	LogFacility               string   `confkey:"logfacility" default:"user"`
	LibDir                    []string `confkey:"libdir" type:"path_split"`
	Identity                  string   `confkey:"identity"`
	DirectAddressing          bool     `confkey:"direct_addressing" default:"true"`
	DirectAddressingThreshold int      `confkey:"direct_addressing_threshold" default:"10"`
	Color                     bool     `confkey:"color" default:"true"`
	Daemonize                 bool     `confkey:"daemonize" default:"false"`
	SecurityProvider          string   `confkey:"securityprovider" default:"psk" type:"title_string"`
	FactSource                string   `confkey:"factsource" default:"yaml" type:"title_string"`
	Connector                 string   `confkey:"connector" default:"nats" type:"title_string"`
	ClassesFile               string   `confkey:"classesfile" default:"/opt/puppetlabs/puppet/cache/state/classes.txt"`
	DiscoveryTimeout          int      `confkey:"discovery_timeout" default:"2"`
	PublishTimeout            int      `confkey:"publish_timeout" default:"2"`
	ConnectionTimeout         int      `confkey:"connection_timeout"`
	RPCAudit                  bool     `confkey:"rpcaudit" default:"false"`
	RPCAuditProvider          string   `confkey:"rpcauditprovider" type:"title_string"`
	RPCAuthorization          bool     `confkey:"rpcauthorization" default:"false"`
	RPCAuthorizationProvider  string   `confkey:"rpcauthprovider" type:"title_string"`
	RPCLimitMethod            string   `confkey:"rpclimitmethod" default:"first"` // TODO support enums
	LoggerType                string   `confkey:"logger_type" default:"file"`
	FactCacheTime             int      `confkey:"fact_cache_time" default:"300"`
	SSLCipher                 string   `confkey:"ssl_cipher" default:"aes-256-cbc"`
	Threaded                  bool     `confkey:"threaded" default:"false"`
	TTL                       int      `confkey:"ttl" default:"60"`
	DefaultDiscoveryOptions   []string `confkey:"default_discovery_options"`
	DefaultDiscoveryMethod    string   `confkey:"default_discovery_method" default:"mc"`
	SoftShutdown              bool     `confkey:"soft_shutdown" default:"false"`
	SoftShutdownTimeout       int      `confkey:"soft_shutdown_timeout"`
	ActivateAgents            bool     `confkey:"activate_agents" default:"true"`

	Choria *ChoriaPluginConfig
	// contains filtered or unexported fields
}

MCollectiveConfig represents MCollective configuration

func NewConfig

func NewConfig(path string) (*MCollectiveConfig, error)

NewConfig parses a config file and return the config

func (*MCollectiveConfig) HasOption

func (c *MCollectiveConfig) HasOption(option string) bool

HasOption determines if a specific option was set from a config key. The option given would be something like `plugin.choria.use_srv` and true would indicate that it was set by config vs using defaults

type Server

type Server struct {
	Host string
	Port int
}

Server is a representation of a network server host and port

Jump to

Keyboard shortcuts

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