tachyon

package module
v0.0.0-...-0da4f38 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: 28 Imported by: 4

README

tachyon

Build Status

Tachyon is an experimental configuration management tool inspired by ansible implemented in golang.

Ok.. why?

I find the best way to learn something is to try to implement it. I'm curious about ansible's model for configuration management and as a fun weekend project began I this project.

Is this usable?

If you need to run some yaml that executes commands via shell/command, sure! Otherwise no. I'll probably continue to play with it, adding more functionality and fleshing out some ideas I've got.

Oohh what ideas?
  • Exploit golang's single binary module to bootstrap machines and run plays remotely.
  • Use golang's concurrency to make management of large scale changes easy.
  • Use github.com/evanphx/ssh to do integrated ssh
  • Allow creation of modules via templated tasks
Is that a lisp directory I see?

It is! ansible uses python as it's implementation lang and thus also uses it as it's runtime eval language. Obviously I can't do that and I don't wish to runtime eval any golang code. Thus I have opted to embed a simple lisp intepreter (taken and modified from https://github.com/janne/go-lisp) to run code. For instance:

name: Tell everyone things are great
action: shell echo wooooo!
when: $(== everything "awesome")
What should I do with this?

Whatever you want. Play around, tell me what you think about it. Send PRs for crazy ass features!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Arg0 string
View Source
var DefaultConfig = &Config{false}
View Source
var Release string = "dev"

Functions

func DisplayScope

func DisplayScope(s Scope)

func ExpandVars

func ExpandVars(s Scope, args string) (string, error)

func HomeDir

func HomeDir() (string, error)

func ImportVarsFile

func ImportVarsFile(s Scope, path string) error

func Main

func Main(args []string) int

func MakeCommand

func MakeCommand(s Scope, task *Task, args string) (Command, Vars, error)

func RegisterCommand

func RegisterCommand(name string, cmd Command)

func SV

func SV(v interface{}, ok bool) interface{}

Types

type AdhocProgress

type AdhocProgress struct {
	Start time.Time
	// contains filtered or unexported fields
}

func (*AdhocProgress) JSONProgress

func (a *AdhocProgress) JSONProgress(data []byte) error

func (*AdhocProgress) Progress

func (a *AdhocProgress) Progress(str string)

type AnyMap

type AnyMap struct {
	// contains filtered or unexported fields
}

func (AnyMap) Get

func (a AnyMap) Get(key string) (Value, bool)

func (AnyMap) MarshalJSON

func (a AnyMap) MarshalJSON() ([]byte, error)

func (AnyMap) Read

func (a AnyMap) Read() interface{}

type AnyValue

type AnyValue struct {
	// contains filtered or unexported fields
}

func (AnyValue) GetYAML

func (a AnyValue) GetYAML() (string, interface{})

func (AnyValue) MarshalJSON

func (a AnyValue) MarshalJSON() ([]byte, error)

func (AnyValue) Read

func (a AnyValue) Read() interface{}

func (AnyValue) SetYAML

func (a AnyValue) SetYAML(tag string, v interface{}) bool

type ArgParser

type ArgParser interface {
	ParseArgs(s Scope, args string) (Vars, error)
}

type AsyncAction

type AsyncAction struct {
	Task   *Task
	Error  error
	Result *Result
	// contains filtered or unexported fields
}

func (*AsyncAction) Finish

func (a *AsyncAction) Finish(res *Result, err error)

func (*AsyncAction) Init

func (a *AsyncAction) Init(r *Runner)

type CLIReporter

type CLIReporter struct {
	Start time.Time
	// contains filtered or unexported fields
}

func (*CLIReporter) FinishAsyncTask

func (c *CLIReporter) FinishAsyncTask(act *AsyncAction)

func (*CLIReporter) FinishHandlers

func (c *CLIReporter) FinishHandlers(r *Runner)

func (*CLIReporter) FinishTask

func (c *CLIReporter) FinishTask(task *Task, res *Result)

func (*CLIReporter) FinishTasks

func (c *CLIReporter) FinishTasks(r *Runner)

func (*CLIReporter) JSONProgress

func (c *CLIReporter) JSONProgress(data []byte) error

func (*CLIReporter) Progress

func (c *CLIReporter) Progress(str string)

func (*CLIReporter) StartHandlers

func (c *CLIReporter) StartHandlers(r *Runner)

func (*CLIReporter) StartTask

func (c *CLIReporter) StartTask(task *Task, name, args string, vars Vars)

func (*CLIReporter) StartTasks

func (c *CLIReporter) StartTasks(r *Runner)

type Command

type Command interface {
	Run(env *CommandEnv) (*Result, error)
}

type CommandCmd

type CommandCmd struct {
	Command    string `tachyon:"command,required"`
	Creates    string `tachyon:"creates"`
	IgnoreFail bool   `tachyon:"ignore_failure"`
}

func (*CommandCmd) ParseArgs

func (cmd *CommandCmd) ParseArgs(s Scope, args string) (Vars, error)

func (*CommandCmd) Run

func (cmd *CommandCmd) Run(env *CommandEnv) (*Result, error)

type CommandEnv

type CommandEnv struct {
	Env   *Environment
	Paths Paths
	// contains filtered or unexported fields
}

func NewCommandEnv

func NewCommandEnv(env *Environment, task *Task) *CommandEnv

func (*CommandEnv) Progress

func (e *CommandEnv) Progress(str string)

type CommandResult

type CommandResult struct {
	ReturnCode int
	Stdout     []byte
	Stderr     []byte
}

func RunCommand

func RunCommand(env *CommandEnv, parts ...string) (*CommandResult, error)

func RunCommandInEnv

func RunCommandInEnv(env *CommandEnv, unixEnv []string, parts ...string) (*CommandResult, error)

type Commands

type Commands map[string]reflect.Type
var AvailableCommands Commands

type Config

type Config struct {
	ShowCommandOutput bool
}

type CopyCmd

type CopyCmd struct {
	Src  string `tachyon:"src,required"`
	Dest string `tachyon:"dest,required"`
}

func (*CopyCmd) Run

func (cmd *CopyCmd) Run(env *CommandEnv) (*Result, error)

type DownloadCmd

type DownloadCmd struct {
	Url       string `tachyon:"url,required"`
	Dest      string `tachyon:"dest"`
	Sha256sum string `tachyon:"sha256sum"`
	Once      bool   `tachyon:"once"`
}

func (*DownloadCmd) Run

func (d *DownloadCmd) Run(env *CommandEnv) (*Result, error)

type Environment

type Environment struct {
	Vars Scope

	Paths Paths
	// contains filtered or unexported fields
}

func NewEnv

func NewEnv(s Scope, cfg *Config) *Environment

func (*Environment) Cleanup

func (e *Environment) Cleanup()

func (*Environment) ReportJSON

func (e *Environment) ReportJSON()

func (*Environment) SetPaths

func (e *Environment) SetPaths(n Paths) Paths

func (*Environment) TempFile

func (e *Environment) TempFile(prefix string) (*os.File, error)

type Future

type Future struct {
	Task    *Task
	Start   time.Time
	Runtime time.Duration
	// contains filtered or unexported fields
}

func NewFuture

func NewFuture(start time.Time, task *Task, f func() (*Result, error)) *Future

func (*Future) Read

func (f *Future) Read() interface{}

func (*Future) Value

func (f *Future) Value() (*Result, error)

func (*Future) Wait

func (f *Future) Wait()

type FutureScope

type FutureScope struct {
	Scope
	// contains filtered or unexported fields
}

func NewFutureScope

func NewFutureScope(parent Scope) *FutureScope

func (*FutureScope) AddFuture

func (fs *FutureScope) AddFuture(key string, f *Future)

func (*FutureScope) Get

func (fs *FutureScope) Get(key string) (Value, bool)

func (*FutureScope) Results

func (fs *FutureScope) Results() []RunResult

func (*FutureScope) Wait

func (fs *FutureScope) Wait()

type Futures

type Futures map[string]*Future

type JsonChunkReconstitute

type JsonChunkReconstitute struct {
	// contains filtered or unexported fields
}

func (*JsonChunkReconstitute) Input

func (j *JsonChunkReconstitute) Input(data []byte) error

func (*JsonChunkReconstitute) InputMap

func (j *JsonChunkReconstitute) InputMap(m map[string]interface{}, depth int) error

type JsonChunkReporter

type JsonChunkReporter struct {
	Start time.Time
	// contains filtered or unexported fields
}

func (*JsonChunkReporter) FinishAsyncTask

func (c *JsonChunkReporter) FinishAsyncTask(act *AsyncAction)

func (*JsonChunkReporter) FinishHandlers

func (c *JsonChunkReporter) FinishHandlers(r *Runner)

func (*JsonChunkReporter) FinishTask

func (c *JsonChunkReporter) FinishTask(task *Task, res *Result)

func (*JsonChunkReporter) FinishTasks

func (c *JsonChunkReporter) FinishTasks(r *Runner)

func (*JsonChunkReporter) JSONProgress

func (c *JsonChunkReporter) JSONProgress(data []byte) error

func (*JsonChunkReporter) Progress

func (c *JsonChunkReporter) Progress(str string)

func (*JsonChunkReporter) StartHandlers

func (c *JsonChunkReporter) StartHandlers(r *Runner)

func (*JsonChunkReporter) StartTask

func (c *JsonChunkReporter) StartTask(task *Task, name, args string, vars Vars)

func (*JsonChunkReporter) StartTasks

func (c *JsonChunkReporter) StartTasks(r *Runner)

type Map

type Map interface {
	Get(key string) (Value, bool)
}

type Module

type Module struct {
	Name      string
	TaskDatas []TaskData             `yaml:"tasks"`
	RawVars   map[string]interface{} `yaml:"vars"`

	ModVars  Vars
	ModTasks []*Task
}

type ModuleRun

type ModuleRun struct {
	Play        *Play
	Task        *Task
	Module      *Module
	Runner      *Runner
	Scope       Scope
	FutureScope *FutureScope
	Vars        Vars
}

func (*ModuleRun) Run

func (m *ModuleRun) Run(env *CommandEnv) (*Result, error)

type NestedScope

type NestedScope struct {
	Scope Scope
	Vars  Vars
}

func NewNestedScope

func NewNestedScope(parent Scope) *NestedScope

func SpliceOverrides

func SpliceOverrides(cur Scope, override *NestedScope) *NestedScope

func (*NestedScope) Empty

func (n *NestedScope) Empty() bool

func (*NestedScope) Flatten

func (n *NestedScope) Flatten() Scope

func (*NestedScope) Get

func (n *NestedScope) Get(key string) (v Value, ok bool)

func (*NestedScope) Set

func (n *NestedScope) Set(key string, v interface{})

type Notifications

type Notifications []string

type Options

type Options struct {
	Vars        map[string]string `short:"s" long:"set" description:"Set a variable"`
	ShowOutput  bool              `short:"o" long:"output" description:"Show command output"`
	Host        string            `short:"t" long:"host" description:"Run the playbook on another host"`
	Development bool              `long:"dev" description:"Use a dev version of tachyon"`
	CleanHost   bool              `long:"clean-host" description:"Clean the host cache before using"`
	Debug       bool              `short:"d" long:"debug" description:"Show all information about commands"`
	Release     string            `long:"release" description:"The release to use when remotely invoking tachyon"`
	JSON        bool              `long:"json" description:"Output the run details in chunked json"`
	Install     bool              `long:"install" description:"Install tachyon a remote machine"`
}

type Paths

type Paths interface {
	Base() string
	Role(name string) string
	Vars(name string) string
	Task(name string) string
	Handler(name string) string
	File(name string) string
	Meta(name string) string
}

type Play

type Play struct {
	Hosts      string
	Connection string
	Vars       Scope
	VarsFiles  VarsFiles
	Tasks      Tasks
	Handlers   Tasks
	Roles      []string
	Modules    map[string]*Module
	// contains filtered or unexported fields
}

type Playbook

type Playbook struct {
	Path string

	Plays []*Play
	Env   *Environment
	Vars  *NestedScope
	// contains filtered or unexported fields
}

func NewPlaybook

func NewPlaybook(env *Environment, p string) (*Playbook, error)

func (*Playbook) LoadPlays

func (pb *Playbook) LoadPlays(fpath string, s Scope) ([]*Play, error)

type PriorityScope

type PriorityScope struct {
	// contains filtered or unexported fields
}

func (*PriorityScope) Get

func (p *PriorityScope) Get(key string) (Value, bool)

func (*PriorityScope) Set

func (p *PriorityScope) Set(key string, val interface{})

type ProgressReporter

type ProgressReporter interface {
	Progress(string)
	JSONProgress(data []byte) error
}

type Reporter

type Reporter interface {
	StartTasks(r *Runner)
	FinishTasks(r *Runner)
	StartHandlers(r *Runner)
	FinishHandlers(r *Runner)

	StartTask(task *Task, name, args string, vars Vars)
	FinishTask(task *Task, res *Result)

	FinishAsyncTask(act *AsyncAction)
	Progress(str string)
	JSONProgress(data []byte) error
}

type Result

type Result struct {
	Changed bool
	Failed  bool
	Data    ResultData
}

func FailureResult

func FailureResult(err error) *Result

func NewResult

func NewResult(changed bool) *Result

func RunAdhocCommand

func RunAdhocCommand(cmd Command, args string) (*Result, error)

func RunAdhocTask

func RunAdhocTask(cmd, args string) (*Result, error)

func RunAdhocTaskVars

func RunAdhocTaskVars(td TaskData) (*Result, error)

func WrapResult

func WrapResult(changed bool, data ResultData) *Result

func (*Result) Add

func (r *Result) Add(key string, v interface{})

func (*Result) Get

func (r *Result) Get(key string) (Value, bool)

func (*Result) MarshalJSON

func (r *Result) MarshalJSON() ([]byte, error)

type ResultData

type ResultData map[string]Value

func (ResultData) Get

func (rd ResultData) Get(key string) interface{}

func (ResultData) Set

func (rd ResultData) Set(key string, v interface{})

type RunResult

type RunResult struct {
	Task    *Task
	Result  *Result
	Runtime time.Duration
}

type Runner

type Runner struct {
	Results []RunResult
	Start   time.Time
	Runtime time.Duration
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(env *Environment, plays []*Play) *Runner

func RunCapture

func RunCapture(path string) (*Runner, string, error)

func (*Runner) AddNotify

func (r *Runner) AddNotify(n string)

func (*Runner) AsyncChannel

func (r *Runner) AsyncChannel() chan *AsyncAction

func (*Runner) Run

func (r *Runner) Run(env *Environment) error

func (*Runner) SetReport

func (r *Runner) SetReport(rep Reporter)

func (*Runner) ShouldRunHandler

func (r *Runner) ShouldRunHandler(name string) bool

type SSH

type SSH struct {
	Host   string
	Config string
	Debug  bool
	// contains filtered or unexported fields
}

func NewSSH

func NewSSH(host string) *SSH

func (*SSH) Cleanup

func (s *SSH) Cleanup()

func (*SSH) Command

func (s *SSH) Command(args ...string) *exec.Cmd

func (*SSH) CommandWithOptions

func (s *SSH) CommandWithOptions(cmd string, args ...string) []string

func (*SSH) CopyToHost

func (s *SSH) CopyToHost(src, dest string) error

func (*SSH) ImportVagrant

func (s *SSH) ImportVagrant(target string) bool

func (*SSH) RsyncCommand

func (s *SSH) RsyncCommand() string

func (*SSH) Run

func (s *SSH) Run(args ...string) error

func (*SSH) RunAndCapture

func (s *SSH) RunAndCapture(args ...string) ([]byte, error)

func (*SSH) RunAndShow

func (s *SSH) RunAndShow(args ...string) error

func (*SSH) SSHCommand

func (s *SSH) SSHCommand(cmd string, args ...string) []string

func (*SSH) Start

func (s *SSH) Start() error

type Scope

type Scope interface {
	Get(key string) (Value, bool)
	Set(key string, val interface{})
}

type ScopeGetter

type ScopeGetter interface {
	Get(key string) (Value, bool)
}

type ScriptCmd

type ScriptCmd struct {
	Script     string `tachyon:"command,required"`
	Creates    string `tachyon:"creates"`
	IgnoreFail bool   `tachyon:"ignore_failure"`
}

func (*ScriptCmd) ParseArgs

func (cmd *ScriptCmd) ParseArgs(s Scope, args string) (Vars, error)

func (*ScriptCmd) Run

func (cmd *ScriptCmd) Run(env *CommandEnv) (*Result, error)

type SeparatePaths

type SeparatePaths struct {
	Top  string
	Root string
}

func (SeparatePaths) Base

func (s SeparatePaths) Base() string

func (SeparatePaths) File

func (s SeparatePaths) File(name string) string

func (SeparatePaths) Handler

func (s SeparatePaths) Handler(name string) string

func (SeparatePaths) Meta

func (s SeparatePaths) Meta(name string) string

func (SeparatePaths) Role

func (s SeparatePaths) Role(name string) string

func (SeparatePaths) Task

func (s SeparatePaths) Task(name string) string

func (SeparatePaths) Vars

func (s SeparatePaths) Vars(name string) string

type ShellCmd

type ShellCmd struct {
	Command    string `tachyon:"command,required"`
	Creates    string `tachyon:"creates"`
	IgnoreFail bool   `tachyon:"ignore_failure"`
}

func (*ShellCmd) ParseArgs

func (cmd *ShellCmd) ParseArgs(s Scope, args string) (Vars, error)

func (*ShellCmd) Run

func (cmd *ShellCmd) Run(env *CommandEnv) (*Result, error)

type SimplePath

type SimplePath struct {
	Root string
}

func (SimplePath) Base

func (s SimplePath) Base() string

func (SimplePath) File

func (s SimplePath) File(name string) string

func (SimplePath) Handler

func (s SimplePath) Handler(name string) string

func (SimplePath) Meta

func (s SimplePath) Meta(name string) string

func (SimplePath) Role

func (s SimplePath) Role(name string) string

func (SimplePath) Task

func (s SimplePath) Task(name string) string

func (SimplePath) Vars

func (s SimplePath) Vars(name string) string

type StrMap

type StrMap struct {
	// contains filtered or unexported fields
}

func (StrMap) Get

func (a StrMap) Get(key string) (Value, bool)

func (StrMap) MarshalJSON

func (a StrMap) MarshalJSON() ([]byte, error)

func (StrMap) Read

func (a StrMap) Read() interface{}

type Tachyon

type Tachyon struct {
	Target      string `tachyon:"target"`
	Debug       bool   `tachyon:"debug"`
	Clean       bool   `tachyon:"clean"`
	Dev         bool   `tachyon:"dev"`
	Playbook    string `tachyon:"playbook"`
	Release     string `tachyon:"release"`
	NoJSON      bool   `tachyon:"no_json"`
	InstallOnly bool   `tachyon:"install_only"`
}

func (*Tachyon) Run

func (t *Tachyon) Run(env *CommandEnv) (*Result, error)

type Task

type Task struct {
	Play *Play
	File string

	Vars Vars

	IncludeVars Vars
	Paths       Paths
	// contains filtered or unexported fields
}

func AdhocTask

func AdhocTask(cmd, args string) *Task

func (*Task) Args

func (t *Task) Args() string

func (*Task) Async

func (t *Task) Async() bool

func (*Task) Command

func (t *Task) Command() string

func (*Task) Future

func (t *Task) Future() string

func (*Task) Init

func (t *Task) Init(env *Environment) error

func (*Task) Items

func (t *Task) Items() []interface{}

func (*Task) Name

func (t *Task) Name() string

func (*Task) Notify

func (t *Task) Notify() []string

func (*Task) Register

func (t *Task) Register() string

func (*Task) When

func (t *Task) When() string

type TaskData

type TaskData map[string]interface{}

type Tasks

type Tasks []*Task

type Value

type Value interface {
	Read() interface{}
}

func Any

func Any(v interface{}) Value

type Vars

type Vars map[string]Value

func ParseSimpleMap

func ParseSimpleMap(s Scope, args string) (Vars, error)

func VarsFromStrMap

func VarsFromStrMap(sm map[string]string) Vars

func (Vars) Copy

func (v Vars) Copy() Vars

type VarsFiles

type VarsFiles []interface{}

Directories

Path Synopsis
net
s3
apt

Jump to

Keyboard shortcuts

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