import "github.com/purpleidea/mgmt/remote"
Package remote provides the remoting facilities for agentless execution. This set of structs and methods are for running mgmt remotely over SSH. This gives us the architectural robustness of our current design, combined with the ability to run it with an "agent-less" approach for bootstrapping, and in environments with more restrictive installation requirements. In general the following sequence is run:
1) connect to remote host 2) make temporary directory 3) copy over the mgmt binary and graph definition 4) tunnel tcp connections for etcd 5) run it! 6) finish and quit 7) close tunnels 8) clean up 9) disconnect
The main advantage of this agent-less approach, is while multiple of these remote mgmt transient agents are running, they can still exchange data and converge together without directly connecting, since they all tunnel through the etcd server running on the initiator.
Flags are constants required by the remote lib.
type Remotes struct {
// contains filtered or unexported fields
}The Remotes struct manages a set of SSH connections. TODO: rename this to something more logical
func NewRemotes(clientURLs, remoteURLs []string, noop bool, remotes []string, fileWatch chan string, cConns uint16, interactive bool, sshPrivIdRsa string, caching bool, depth uint16, prefix string, converger cv.Converger, convergerCb func(func(map[string]bool) error) (func(), error), flags Flags) *Remotes
NewRemotes builds a Remotes struct.
Exit causes as much of the Remotes struct to shutdown as quickly and as cleanly as possible. It only returns once everything is shutdown.
NewSSH is a helper function that does the initial parsing into an SSH obj. It takes as input the path to a graph definition file.
Run kicks it all off. It is usually run from a go routine.
type SSH struct {
// contains filtered or unexported fields
}The SSH struct is the unit building block for a single remote SSH connection.
Close cleans up after the main SSH connection.
Connect kicks off the SSH connection.
Exec runs the binary on the remote server.
ExecExit sends a SIGINT (^C) signal to the remote process, and waits for the process to exit.
Go kicks off the entire sequence of one SSH connection.
Sftp is a function for the sftp protocol to create a remote dir and copy over the binary to run. On error the string represents the path to the remote dir.
SftpClean cleans up the mess and closes the connection from the sftp work.
SftpCopy is a simple helper function that runs a local -> remote sftp copy.
SftpGraphCopy is a helper function used for re-copying the graph definition.
SftpHash hashes a local file, and compares that hash to the result of a remote hashing command run on the second file path.
Stop shuts down any SSH in progress as safely and quickly as possible.
Tunnel initiates the reverse SSH tunnel. You can .Wait() on the returned sync WaitGroup to know when the tunnels have closed completely.
TunnelClose causes any currently connected Tunnel to shutdown.
Package remote imports 27 packages (graph) and is imported by 2 packages. Updated 2017-03-05. Refresh now. Tools for package owners.