Documentation
¶
Index ¶
- Variables
- func Prompt(keys []PendingKey, w io.Writer, r io.Reader) (bool, error)
- func Run(ctx context.Context, servers []string, cmd string, opts Opts) error
- func Version() string
- func WriteStats(w io.Writer, archive map[*Job]error) error
- func WriteToKnownHosts(keys []PendingKey) error
- type HistoryItem
- type HostConfig
- type HostResult
- type Job
- func (j *Job) Cleanup(ctx context.Context) error
- func (j *Job) Close() error
- func (j *Job) Dial(ctx context.Context) error
- func (j *Job) Download(ctx context.Context) error
- func (j *Job) Exec(ctx context.Context) error
- func (j *Job) Start(ctx context.Context) error
- func (j *Job) Upload(ctx context.Context) error
- type KeyCollector
- type Opts
- type Output
- type PendingKey
- type SSHConfigResolver
- type Tasks
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Prompt ¶ added in v0.3.0
Prompt prints the pending keys to w and asks the user to confirm via r. Returns true if the user accepted.
func Run ¶
Run parallel SSH command executions across multiple servers with automatic retry, output aggregation, and optional execution history.
func WriteStats ¶
WriteStats summary by reading the jobs' errors and performing some deductions.
func WriteToKnownHosts ¶ added in v0.3.0
func WriteToKnownHosts(keys []PendingKey) error
WriteToKnownHosts appends keys to ~/.ssh/known_hosts, creating the file (and ~/.ssh/ directory) if they do not yet exist.
Types ¶
type HistoryItem ¶
type HistoryItem struct {
Path string
Time time.Time
Duration time.Duration
Hosts map[string]HostResult
Files []string
Logs []string
Command string
}
func ListHistory ¶
func ListHistory(root string) ([]HistoryItem, error)
func (HistoryItem) Delete ¶
func (hi HistoryItem) Delete() error
Delete the underlying state directory.
func (HistoryItem) Read ¶
func (hi HistoryItem) Read(p []byte) (n int, err error)
Read implements io.Reader.
func (HistoryItem) Summary ¶ added in v0.2.0
func (hi HistoryItem) Summary() (succeeded, failed int)
Summary returns counts of succeeded and failed hosts.
type HostConfig ¶ added in v0.3.0
HostConfig holds parsed SSH settings for a single host.
type HostResult ¶ added in v0.2.0
type HostResult struct {
Error string `json:"error,omitempty"`
Tries int `json:"tries"`
Duration time.Duration `json:"duration"`
}
HostResult captures the final execution state for a single host.
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job represents a single task to be executed on a single host. A job holds its information while going through retries until completion or exhaustion.
func (*Job) Close ¶
Close implements io.Closer. Close is idempotent; calling it multiple times returns nil after the first call.
type KeyCollector ¶ added in v0.3.0
type KeyCollector struct {
// contains filtered or unexported fields
}
KeyCollector accumulates unknown host keys encountered during SSH dials. It is safe for concurrent use.
func (*KeyCollector) Callback ¶ added in v0.3.0
func (c *KeyCollector) Callback(base ssh.HostKeyCallback) ssh.HostKeyCallback
Callback wraps an existing ssh.HostKeyCallback. The returned callback:
- passes through nil (key is known and matches)
- records unknown hosts in the collector and returns nil so the dial succeeds
- returns the error unchanged for changed keys (potential MITM)
func (*KeyCollector) Keys ¶ added in v0.3.0
func (c *KeyCollector) Keys() []PendingKey
Keys returns all collected unknown-host keys. Safe to call after Run returns.
type Opts ¶
type Opts struct {
User string
Port int
Retries int
Workers int
Files []string
ConnTimeout time.Duration
ExecTimeout time.Duration
History bool
HistoryPath string
UploadPath string
Insecure bool
DownloadPath string
Tasks Tasks
KeyCollector *KeyCollector
}
Opts carries CLI arguments from ./cmd into Run(). Values are copied into each Job at creation time - jobs don't share this struct.
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
Output is used to relay remove execution's output into the history (if enabled), while also teeing the output to stdout.
func NewOutput ¶
NewOutput creates new output with given prefix, without underlaying file, printing to os.Stdout.
func (*Output) SetFile ¶
func (o *Output) SetFile(f io.WriteCloser)
SetFile sets f as underlaying file.
type PendingKey ¶ added in v0.3.0
PendingKey holds an unknown host key encountered during an SSH dial.
type SSHConfigResolver ¶ added in v0.3.0
type SSHConfigResolver func(alias string) HostConfig
SSHConfigResolver looks up per-host SSH config settings.