cli, etcd, lib: Add an etcd client over ssh world backend
This provides a new kind of "world" backend, one that runs etcd over an SSH connection. This is useful for situations where you want to run an etcd cluster somewhere for clients across the net, but where you don't want to expose the ports publicly. If SSH authentication is setup correctly (using public keys) this will tunnel over SSH for etcd to connect. This patch does not yet support deploys over SSH, but that should be fixed in the future as the world code gets cleaned up more.
This commit is contained in:
32
lib/main.go
32
lib/main.go
@@ -52,6 +52,7 @@ import (
|
||||
"github.com/purpleidea/mgmt/etcd/chooser"
|
||||
etcdClient "github.com/purpleidea/mgmt/etcd/client"
|
||||
etcdInterfaces "github.com/purpleidea/mgmt/etcd/interfaces"
|
||||
etcdSSH "github.com/purpleidea/mgmt/etcd/ssh"
|
||||
"github.com/purpleidea/mgmt/gapi"
|
||||
"github.com/purpleidea/mgmt/gapi/empty"
|
||||
"github.com/purpleidea/mgmt/pgp"
|
||||
@@ -148,6 +149,15 @@ type Config struct {
|
||||
// this many seconds. Use 0 to disable this.
|
||||
MaxRuntime uint `arg:"--max-runtime,env:MGMT_MAX_RUNTIME" help:"exit after a maximum of approximately this many seconds"`
|
||||
|
||||
// SshUrl can be specified if we want to transport the SSH client
|
||||
// connection over SSH. If this is specified, the second hop is made
|
||||
// with the Seeds values, but they connect from this destination. You
|
||||
// can specify this in the standard james@server:22 format. This will
|
||||
// use your ~/.ssh/ directory for public key authentication and
|
||||
// verifying the host key in the known_hosts file. This must already be
|
||||
// setup for things to work.
|
||||
SshUrl string `arg:"--ssh-url" help:"transport the etcd client connection over SSH to this server"`
|
||||
|
||||
// Seeds are the list of default etcd client endpoints. If empty, it
|
||||
// will startup a new server.
|
||||
Seeds []string `arg:"--seeds,env:MGMT_SEEDS" help:"default etcd client endpoints"`
|
||||
@@ -611,8 +621,9 @@ func (obj *Main) Run() error {
|
||||
// an etcd component from the etcd package added in.
|
||||
var world engine.World
|
||||
world = &etcd.World{
|
||||
Hostname: hostname,
|
||||
Client: client,
|
||||
Hostname: hostname,
|
||||
Client: client,
|
||||
//NS: NS,
|
||||
MetadataPrefix: MetadataPrefix,
|
||||
StoragePrefix: StoragePrefix,
|
||||
StandaloneFs: obj.DeployFs, // used for static deploys
|
||||
@@ -623,6 +634,23 @@ func (obj *Main) Run() error {
|
||||
return gapiInfoResult.URI
|
||||
},
|
||||
}
|
||||
if obj.SshUrl != "" { // alternate world implementation over SSH
|
||||
world = &etcdSSH.World{
|
||||
URL: obj.SshUrl,
|
||||
Seeds: obj.Seeds,
|
||||
Hostname: hostname,
|
||||
NS: NS,
|
||||
MetadataPrefix: MetadataPrefix,
|
||||
StoragePrefix: StoragePrefix,
|
||||
StandaloneFs: obj.DeployFs, // used for static deploys
|
||||
GetURI: func() string {
|
||||
if gapiInfoResult == nil {
|
||||
return ""
|
||||
}
|
||||
return gapiInfoResult.URI
|
||||
},
|
||||
}
|
||||
}
|
||||
worldInit := &engine.WorldInit{
|
||||
Debug: obj.Debug,
|
||||
Logf: func(format string, v ...interface{}) {
|
||||
|
||||
Reference in New Issue
Block a user