Documentation ¶
Index ¶
Constants ¶
const ( // ExecModeCmdByCmd means execute a command in all relative hosts and then continue to next command // eg. cmd1: host1,host2, cmd2:host1, host2 ExecModeCmdByCmd int = iota // ExecModeHostByHost means execute a host relative commands and the continue to next host. // eg .host1: cmd1,cmd2, host2:cmd1, cmd2 ExecModeHostByHost )
Variables ¶
var LocalHost = &Host{ID: "localhost", Addr: "localhost"}
LocalHost means the local host. nolint gochecknoglobals
Functions ¶
func ExecInHosts ¶ added in v1.0.0
ExecInHosts execute in specified hosts.
func GetLastLine ¶ added in v1.0.0
GetLastLine gets the last line of s.
Types ¶
type CmdChanClosed ¶ added in v1.0.0
type CmdChanClosed struct{}
CmdChanClosed represents the cmd channel closed event.
type Config ¶
type Config struct { ReplaceQuote string `pflag:"replace for quote(\"). shorthand=q"` ReplaceBang string `pflag:"replace for bang(!). shorthand=b"` Separator string `pflag:"separator for hosts, cmds, default comma. shorthand=s"` NetTimeout string `pflag:"timeout(eg. 15s, 3m), empty for no timeout."` CmdTimeout string `pflag:"timeout(eg. 15s, 3m), default 15m."` SplitSSH bool `pflag:"split ssh commands by comma or not. shorthand=S"` PrintConfig bool `pflag:"print config before running. shorthand=P"` Passphrase string `pflag:"passphrase for decrypt {PBE}Password. shorthand=p"` Hosts []string `pflag:"hosts. shorthand=H"` Cmds []string `pflag:"commands to be executedChan. shorthand=C"` User string `pflag:"user. shorthand=u"` Pass string `pflag:"pass."` HostsFile string `pflag:"hosts file. shorthand=f"` CmdsFile string `pflag:"cmds file."` ExecMode int `pflag:"exec mode(0: cmd by cmd, 1 host by host). shorthand=e"` // contains filtered or unexported fields }
Config represents the structure of input toml file structure.
func (Config) GetSeparator ¶ added in v1.0.0
GetSeparator get the separator
type Host ¶
type Host struct { ID string Addr string User string Password string // empty when using public key Properties map[string]string Proxy *Host // contains filtered or unexported fields }
Host represents the structure of remote host information for ssh.
func (*Host) GetGosshConnect ¶ added in v1.0.0
GetGosshConnect get gossh Connect
func (*Host) GetSftpClient ¶ added in v1.0.0
GetSftpClient get sftClient by host
func (Host) PrintSCP ¶ added in v1.0.0
func (h Host) PrintSCP()
PrintSCP prints sshpass scp commands
func (*Host) PrintSSH ¶ added in v1.0.0
func (h *Host) PrintSSH()
PrintSSH prints sshpass ssh commands
type Hosts ¶ added in v1.0.0
type Hosts []*Host
Hosts stands for slice of Host
func (Hosts) FixHostID ¶ added in v1.0.0
func (hosts Hosts) FixHostID()
FixHostID fix the host ID by sequence if it is blank.
type HostsCmd ¶ added in v1.0.0
type HostsCmd interface { // Parse parses the command. Parse() // Exec execute in specified host. Exec(gs *GoSSH, host *Host) error // TargetHosts returns target hosts for the command TargetHosts() Hosts }
HostsCmd means the executable interface
type LocalCmd ¶
type LocalCmd struct {
// contains filtered or unexported fields
}
LocalCmd means local commands.
func (LocalCmd) TargetHosts ¶ added in v1.0.0
TargetHosts returns target hosts for the command
type SSHCmd ¶
type SSHCmd struct {
// contains filtered or unexported fields
}
SSHCmd means SSH command.
func (*SSHCmd) TargetHosts ¶ added in v1.0.0
TargetHosts returns target hosts for the command
type UlCmd ¶ added in v0.2.0
type UlCmd struct { UlDl // contains filtered or unexported fields }
UlCmd upload cmd structure.
type UlDl ¶ added in v0.2.0
type UlDl struct {
// contains filtered or unexported fields
}
UlDl scp...
func (*UlDl) TargetHosts ¶ added in v1.0.0
TargetHosts returns target hosts for the command