henchman

package
v0.0.0-...-de003f1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2015 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ECHO          = 53
	TTY_OP_ISPEED = 128
	TTY_OP_OSPEED = 129
)

Variables

This section is empty.

Functions

func ClientKeyAuth

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

func PasswordAuth

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

func UpdateTasks

func UpdateTasks(tasksPtr *[]Task, vars TaskVars, ndx int, machine Machine) error

Updates the task list if there is a valid include param for each include param it will update the vars context if it's provided.

Types

type LocalTransport

type LocalTransport struct{}

func NewLocal

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

func (*LocalTransport) Exec

func (localTransport *LocalTransport) Exec(action string) (*bytes.Buffer, error)

func (*LocalTransport) Initialize

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

type Machine

type Machine struct {
	Hostname  string
	Transport TransportInterface
}

type Plan

type Plan struct {
	Hosts []string
	Tasks []Task `yaml:"tasks"`
	Vars  TaskVars
	Name  string
	// contains filtered or unexported fields
}

A plan is a collection of tasks. All the tasks are executed serially, although the same plan is run concurrently on multiple machines

func NewPlanFromYAML

func NewPlanFromYAML(planBuf []byte, hostsFileBuf []byte, overrides TaskVars) (*Plan, error)

Returns a new plan with a collection of tasks. The planBuf and hostsFileBuf should be a valid 'yaml' representation. Additionally, this function also takes in any variable overrides that takes precedence over the variables present in the plan.

func (*Plan) PrintReport

func (plan *Plan) PrintReport()

Prints the summary of the Plan execution across all the hosts

func (*Plan) SaveStatus

func (plan *Plan) SaveStatus(task *Task, status string)

Mark a given task's status. NOTE: Skipped tasks are not tracked here.

func (*Plan) String

func (plan *Plan) String() string

type RegisterOutput

type RegisterOutput struct {
	Stdout string
	Stderr string
	Rc     string
}

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(action string) (*bytes.Buffer, error)

func (*SSHTransport) Initialize

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

type Task

type Task struct {
	Id           string
	Name         string
	Action       string
	Register     string
	Include      string
	When         string
	Vars         TaskVars
	IgnoreErrors bool `yaml:"ignore_errors"`
	LocalAction  bool `yaml:"local"`
}

Task is the unit of work in henchman.

func PrepareTasks

func PrepareTasks(tasks []Task, vars TaskVars, machine Machine) ([]Task, error)

change this to be a non-plan function come back to context variable stuff after getting include done look at diagram renders Task list, uses vars and machine for context

func (*Task) ProcessWhen

func (task *Task) ProcessWhen(regMap map[string]interface{}) (bool, error)

Processes When param of a task. Evaluates it using pongo2 and uses a registerMap (populated by other tasks register variables) as the context

func (*Task) Run

func (task *Task) Run(machine *Machine, regMap map[string]interface{}) (*TaskStatus, error)
func prepareTemplate(data string, vars *TaskVars, machine *Machine) (string, error) {
	tmpl, err := pongo2.FromString(data)
	if err != nil {
		panic(err)
	}
	ctxt := pongo2.Context{"vars": vars, "machine": machine}
	return tmpl.Execute(ctxt)
}

// Renders the template parts in the task field. // Also assigns a new UUID to the task uniquely identifying it.

func (task *Task) prepare(vars *TaskVars, machine *Machine) {
	var err error
	task.Id = uuid.New()
	task.Name, err = prepareTemplate(task.Name, vars, machine)
	if err != nil {
		panic(err)
	}
	task.Action, err = prepareTemplate(task.Action, vars, machine)
	if err != nil {
		panic(err)
	}
}

Runs the task on the machine. The task might mutate `vars` so that other tasks down the `plan` can see any additions/updates.

type TaskStatus

type TaskStatus struct {
	Status  string
	Message string
}

type TaskVars

type TaskVars map[string]interface{}

type TransportConfig

type TransportConfig map[string]string

type TransportInterface

type TransportInterface interface {
	Initialize(config *TransportConfig) error
	Exec(action string) (*bytes.Buffer, error)
}

Jump to

Keyboard shortcuts

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