henchman

package
v0.0.0-...-b3158f8 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2015 License: BSD-2-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HENCHMAN_PREFIX = "henchman_"
	TARGET          = "modules.tar"
)
View Source
const (
	ECHO          = 53
	TTY_OP_ISPEED = 128
	TTY_OP_OSPEED = 129
)

Variables

View Source
var (
	DebugFlag bool
)
View Source
var ModuleSearchPath = []string{
	"modules",
}

Functions

func ClientKeyAuth

func ClientKeyAuth(keyFile string) (ssh.AuthMethod, error)

func Debug

func Debug(fields map[string]interface{}, msg string)

wrapper for debug

func ErrKeyword

func ErrKeyword(val interface{}) error

func ErrNotValidVariable

func ErrNotValidVariable(val interface{}) error

func ErrWrongType

func ErrWrongType(field interface{}, val interface{}, _type string) error

func Error

func Error(fields map[string]interface{}, msg string)

wrapper for Error

func Fatal

func Fatal(fields map[string]interface{}, msg string)

wrapper for Fatal

func GetInventoryGroups

func GetInventoryGroups(planBuf []byte) ([]string, error)

*

  • gets the groups under hosts section from plan file

func HenchErr

func HenchErr(err error, fields map[string]interface{}, extMsg string) error

func Info

func Info(fields map[string]interface{}, msg string)

wrapper for Info

func InitConfiguration

func InitConfiguration(filename string) error

func InitLog

func InitLog()

func MergeLogrusFields

func MergeLogrusFields(src map[string]interface{}, dst map[string]interface{}, override bool)

func MergeMap

func MergeMap(src map[interface{}]interface{}, dst map[interface{}]interface{}, override bool)

*

  • These functions deal with merging of maps

source values will override dest values if override is true else dest values will not be overridden

func PasswordAuth

func PasswordAuth(pass string) (ssh.AuthMethod, error)

func Printf

func Printf(msg string, a ...interface{})

wrapper for Printf and Println with a lock

func PrintfAndFill

func PrintfAndFill(size int, fill string, msg string, a ...interface{})

Does a printf and fills the extra white space Just specify the max size to fill to and the string to fill with

func Println

func Println(msg string)

func SprintfAndFill

func SprintfAndFill(size int, fill string, msg string, a ...interface{}) string

Does a Sprintf and fills the extra white space

func Warn

func Warn(fields map[string]interface{}, msg string)

Types

type Configuration

type Configuration struct {
	Log       string
	ExecOrder map[string][]string
}
var Config Configuration

Global config object for henchman to use

type CustomUnmarshalError

type CustomUnmarshalError struct {
	Err error
}

func (*CustomUnmarshalError) Error

func (cue *CustomUnmarshalError) Error() string

type HenchmanError

type HenchmanError struct {
	Err    error
	Fields map[string]interface{}
	// contains filtered or unexported fields
}

func (*HenchmanError) Error

func (henchError *HenchmanError) Error() string

type HostGroup

type HostGroup struct {
	Hosts []string                    `yaml:"hosts"`
	Vars  map[interface{}]interface{} `yaml:"vars"`
}

type Inventory

type Inventory struct {
	//GroupHosts map[string][]*Machine
	Groups     map[string]HostGroup                   `yaml:"groups"`
	HostVars   map[string]map[interface{}]interface{} `yaml:"host_vars"`
	GlobalVars map[interface{}]interface{}            `yaml:"global_vars"`
}

type Inventory map[string][]*Machine

func (Inventory) Count

func (inv Inventory) Count() int

func (*Inventory) GetInventoryForGroups

func (inv *Inventory) GetInventoryForGroups(groups []string) Inventory

*

  • Returns a filtered inventory depending on which groups are specified
  • Keeps the groups specified in the filtered inventory

func (*Inventory) GetMachines

func (inv *Inventory) GetMachines(tc TransportConfig) ([]*Machine, error)

type InventoryConfig

type InventoryConfig map[string]string

type InventoryInterface

type InventoryInterface interface {
	Load(ic InventoryConfig) (Inventory, error)
}

type LocalTransport

type LocalTransport struct{}

Transport for the current machine on which henchman is being run on

func NewLocal

func NewLocal(config *TransportConfig) (*LocalTransport, error)

func (*LocalTransport) Exec

func (local *LocalTransport) Exec(cmdStr string, stdin []byte, sudoEnabled bool) (*bytes.Buffer, error)

func (*LocalTransport) Initialize

func (local *LocalTransport) Initialize(config *TransportConfig) error

func (*LocalTransport) Put

func (local *LocalTransport) Put(source, destination string, _ string) error

type Machine

type Machine struct {
	Hostname  string
	Vars      VarsMap
	Transport TransportInterface
}

type Module

type Module struct {
	Name   string
	Params map[string]string
}

FIXME: Have custom error types when parsing modules

func NewModule

func NewModule(name string, params string) (Module, error)

func (Module) ExecOrder

func (module Module) ExecOrder() ([]string, error)

func (Module) Resolve

func (module Module) Resolve() (string, bool, error)

Checks to see if a modules is valid and if it's a standalone module

type Plan

type Plan struct {
	Name      string
	Inventory Inventory
	Vars      VarsMap
	Tasks     []*Task
}

func PreprocessPlan

func PreprocessPlan(buf []byte, inv *Inventory) (*Plan, error)

For Plan

func (*Plan) Cleanup

func (plan *Plan) Cleanup(machines []*Machine) error

For now it just removes the .henchman folder in each system

func (*Plan) Execute

func (plan *Plan) Execute(machines []*Machine) error

Does execution of tasks

func (*Plan) Setup

func (plan *Plan) Setup(machines []*Machine) error

*

  • These functions are functions that can be utilized by plans

Moves all modules to each host

type PlanProxy

type PlanProxy struct {
	Name            string       `yaml:"name"`
	Sudo            bool         `yaml:"sudo"`
	Debug           bool         `yaml:"debug"`
	TaskProxies     []*TaskProxy `yaml:"tasks"`
	VarsProxy       *VarsProxy   `yaml:"vars"`
	InventoryGroups []string     `yaml:"hosts"`
}

func (PlanProxy) PreprocessTasks

func (px PlanProxy) PreprocessTasks() ([]*Task, error)

Checks the a slice of TaskProxy ptrs passed in by a Plan and determines whether if it's an include value or a normal task. If it's a normal task it appends it as a standard task, otherwise it recursively expands the include statement NOTE: making this a function of PlanProxy in case we want to have more plan level variables

in the future.  Removes the need to pass each variable as a parameter.

func (PlanProxy) PreprocessVars

func (px PlanProxy) PreprocessVars() (VarsMap, error)

Processes plan level vars with includes All plan level vars will be in the vars map And any repeat vars in the includes will be a FCFS priority NOTE: if the user has multiple include blocks it'll grab the one closest to

the bottom

type RegMap

type RegMap map[string]interface{}

type SSHTransport

type SSHTransport struct {
	Host   string
	Port   uint16
	Config *ssh.ClientConfig
}

func NewSSH

func NewSSH(config *TransportConfig) (*SSHTransport, error)

func (*SSHTransport) Exec

func (sshTransport *SSHTransport) Exec(cmd string, stdin []byte, sudoEnabled bool) (*bytes.Buffer, error)

func (*SSHTransport) Initialize

func (sshTransport *SSHTransport) Initialize(config *TransportConfig) error

func (*SSHTransport) Put

func (sshTransport *SSHTransport) Put(source, destination string, srcType string) error

source is the source of the file/folder destination is the path of the FOLDER where source will be transferred to NOTE: source will keep it original name when transferred

type Task

type Task struct {
	Id           string
	Debug        bool
	IgnoreErrors bool `yaml:"ignore_errors"`
	Local        bool
	Module       Module
	Name         string
	Register     string
	Retry        int
	Sudo         bool
	Vars         VarsMap
	When         string
}

func (*Task) ProcessWhen

func (task *Task) ProcessWhen() (bool, error)

checks and converts when to bool

func (Task) Render

func (task Task) Render(vars VarsMap, registerMap RegMap) (Task, error)

wrapper for Rendering each task This will return the rendered task and not manipulate the pointer to the task. b/c the pointer to the task is a template and a race condition can occur.

func (*Task) Run

func (task *Task) Run(machine *Machine, vars VarsMap, registerMap RegMap) (*TaskResult, error)

type TaskProxy

type TaskProxy struct {
	Task        `yaml:",inline"`
	SudoState   string
	DebugState  string
	Include     string
	IncludeVars VarsMap `yaml:"vars"`
}

Task is for the general Task format. Refer to task.go Vars are kept in scope for each Task. So there is a Vars field for each task Include is the file name for the included Tasks list

func (*TaskProxy) UnmarshalYAML

func (tp *TaskProxy) UnmarshalYAML(unmarshal func(interface{}) error) error

Custom unmarshaller which accounts for module names

type TaskResult

type TaskResult struct {
	State  string      `json:"status"`
	Output interface{} `json:"output,omitempty"`
	Msg    string      `json:"msg"`
}

type TransportConfig

type TransportConfig map[string]string

type TransportInterface

type TransportInterface interface {
	Initialize(config *TransportConfig) error
	Exec(cmd string, stdin []byte, sudo bool) (*bytes.Buffer, error)
	Put(source string, destination string, dstType string) error
}

type VarsMap

type VarsMap map[interface{}]interface{}

func GetHenchmanVars

func GetHenchmanVars(vars VarsMap) VarsMap

*

  • Gets any vars with the prefix henchman

type VarsProxy

type VarsProxy struct {
	Vars VarsMap
}

func (*VarsProxy) UnmarshalYAML

func (vp *VarsProxy) UnmarshalYAML(unmarshal func(interface{}) error) error

Custom unmarshaller which account for multiple include statements and include types NOTE: Cannot account for double includes because unmarshal(&vMap) already does

under the hood unmarshaling and does what any map would do, which is override
repeating key values

type YAMLInventory

type YAMLInventory struct {
	Groups     map[string]HostGroup                   `yaml:"groups"`
	HostVars   map[string]map[interface{}]interface{} `yaml:"host_vars"`
	GlobalVars map[interface{}]interface{}            `yaml:"global_vars"`
}

FIXME: Have a way to provide specifics

func (*YAMLInventory) Load

func (yi *YAMLInventory) Load(ic InventoryConfig) (Inventory, error)

Directories

Path Synopsis
Godeps
_workspace/src/code.google.com/p/go-uuid/uuid
The uuid package generates and inspects UUIDs.
The uuid package generates and inspects UUIDs.
_workspace/src/code.google.com/p/go.crypto/ssh
Package ssh implements an SSH client and server.
Package ssh implements an SSH client and server.
_workspace/src/code.google.com/p/go.crypto/ssh/agent
Package agent implements a client to an ssh-agent daemon.
Package agent implements a client to an ssh-agent daemon.
_workspace/src/code.google.com/p/go.crypto/ssh/terminal
Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.
Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.
_workspace/src/code.google.com/p/go.crypto/ssh/test
This package contains integration tests for the code.google.com/p/go.crypto/ssh package.
This package contains integration tests for the code.google.com/p/go.crypto/ssh package.
_workspace/src/github.com/flosch/pongo2
A Django-syntax like template-engine Blog posts about pongo2 (including introduction and migration): https://www.florian-schlachter.de/?tag=pongo2 Complete documentation on the template language: https://docs.djangoproject.com/en/dev/topics/templates/ Try out pongo2 live in the pongo2 playground: https://www.florian-schlachter.de/pongo2/ Make sure to read README.md in the repository as well.
A Django-syntax like template-engine Blog posts about pongo2 (including introduction and migration): https://www.florian-schlachter.de/?tag=pongo2 Complete documentation on the template language: https://docs.djangoproject.com/en/dev/topics/templates/ Try out pongo2 live in the pongo2 playground: https://www.florian-schlachter.de/pongo2/ Make sure to read README.md in the repository as well.
_workspace/src/github.com/stretchr/testify/assert
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
_workspace/src/github.com/stretchr/testify/require
Alternative testing tools which stop test execution if test failed.
Alternative testing tools which stop test execution if test failed.
_workspace/src/gopkg.in/yaml.v2
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.

Jump to

Keyboard shortcuts

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