From b08cb2028372a7f094d473693ac55ed7050538b4 Mon Sep 17 00:00:00 2001 From: dmitri Date: Sun, 9 Oct 2016 16:10:17 +0200 Subject: [PATCH 1/3] Preset auth servers in file storage if configuration has auth servers --- lib/service/service.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/service/service.go b/lib/service/service.go index 6603dca18a7..b9714b6cc8a 100644 --- a/lib/service/service.go +++ b/lib/service/service.go @@ -135,6 +135,12 @@ func (process *TeleportProcess) connectToAuthService(role teleport.Role) (*Conne storage := utils.NewFileAddrStorage( filepath.Join(process.Config.DataDir, "authservers.json")) + if len(process.Config.AuthServers) > 0 { + if err := storage.SetAddresses(process.Config.AuthServers); err != nil { + return nil, trace.Wrap(err) + } + } + authUser := identity.Cert.ValidPrincipals[0] authClient, err := auth.NewTunClient( string(role), From ae17875e030005cafe587252386c137825871727 Mon Sep 17 00:00:00 2001 From: dmitri Date: Mon, 10 Oct 2016 12:58:22 +0200 Subject: [PATCH 2/3] Relax the logging level on reading from non-existing authservers.json --- lib/auth/tun.go | 2 +- lib/service/service.go | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/auth/tun.go b/lib/auth/tun.go index 814703b1dc7..abb2dc3ea47 100644 --- a/lib/auth/tun.go +++ b/lib/auth/tun.go @@ -591,7 +591,7 @@ func NewTunClient(purpose string, if tc.addrStorage != nil { cachedAuthServers, err := tc.addrStorage.GetAddresses() if err != nil { - log.Warningf("unable to load the auth server cache: %v", err) + log.Infof("unable to load the auth server cache: %v", err) } else { tc.setAuthServers(cachedAuthServers) } diff --git a/lib/service/service.go b/lib/service/service.go index b9714b6cc8a..6603dca18a7 100644 --- a/lib/service/service.go +++ b/lib/service/service.go @@ -135,12 +135,6 @@ func (process *TeleportProcess) connectToAuthService(role teleport.Role) (*Conne storage := utils.NewFileAddrStorage( filepath.Join(process.Config.DataDir, "authservers.json")) - if len(process.Config.AuthServers) > 0 { - if err := storage.SetAddresses(process.Config.AuthServers); err != nil { - return nil, trace.Wrap(err) - } - } - authUser := identity.Cert.ValidPrincipals[0] authClient, err := auth.NewTunClient( string(role), From 0a78b45b3c9ed12fea9458534954b30313026680 Mon Sep 17 00:00:00 2001 From: Ev Kontsevoy Date: Mon, 10 Oct 2016 10:51:43 -0700 Subject: [PATCH 3/3] Added "examples" directory with some sample configs - 3-node cluster example - systemd unit file --- examples/README.md | 2 ++ examples/local-cluster/.gitignore | 1 + examples/local-cluster/README.md | 11 +++++++++++ examples/local-cluster/auth/start.sh | 2 ++ examples/local-cluster/auth/teleport.yaml | 12 ++++++++++++ examples/local-cluster/node/start.sh | 2 ++ examples/local-cluster/node/teleport.yaml | 12 ++++++++++++ examples/local-cluster/proxy/start.sh | 2 ++ examples/local-cluster/proxy/teleport.yaml | 12 ++++++++++++ examples/local-cluster/tctl.sh | 2 ++ examples/systemd/README.md | 3 +++ examples/systemd/teleport.service | 11 +++++++++++ 12 files changed, 72 insertions(+) create mode 100644 examples/README.md create mode 100644 examples/local-cluster/.gitignore create mode 100644 examples/local-cluster/README.md create mode 100755 examples/local-cluster/auth/start.sh create mode 100644 examples/local-cluster/auth/teleport.yaml create mode 100755 examples/local-cluster/node/start.sh create mode 100644 examples/local-cluster/node/teleport.yaml create mode 100755 examples/local-cluster/proxy/start.sh create mode 100644 examples/local-cluster/proxy/teleport.yaml create mode 100755 examples/local-cluster/tctl.sh create mode 100644 examples/systemd/README.md create mode 100644 examples/systemd/teleport.service diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000000..9db4c6e9e00 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,2 @@ +`local-cluster` : Sample configuration of a 3-node Teleport cluster using just a single machine +`systemd` : Service file for Systemd diff --git a/examples/local-cluster/.gitignore b/examples/local-cluster/.gitignore new file mode 100644 index 00000000000..ea26ec23a73 --- /dev/null +++ b/examples/local-cluster/.gitignore @@ -0,0 +1 @@ +.data diff --git a/examples/local-cluster/README.md b/examples/local-cluster/README.md new file mode 100644 index 00000000000..22e295f5e19 --- /dev/null +++ b/examples/local-cluster/README.md @@ -0,0 +1,11 @@ +# Local Cluster + +This directory contains a sample configuration of a 3-node Teleport cluster +where all 3 components are running as 3 independent processes: + +* Auth : configured with static host tokens +* Proxy: configured to join 'auth' +* Node : configured to join 'auth' + +This is also useful for Teleport development: open all 3 directories in +3 different tabs and run `./start.sh` in each. diff --git a/examples/local-cluster/auth/start.sh b/examples/local-cluster/auth/start.sh new file mode 100755 index 00000000000..c12b94ed292 --- /dev/null +++ b/examples/local-cluster/auth/start.sh @@ -0,0 +1,2 @@ +#!/bin/bash +teleport start -c teleport.yaml -d diff --git a/examples/local-cluster/auth/teleport.yaml b/examples/local-cluster/auth/teleport.yaml new file mode 100644 index 00000000000..7477e36accb --- /dev/null +++ b/examples/local-cluster/auth/teleport.yaml @@ -0,0 +1,12 @@ +teleport: + nodename: graviton-auth + data_dir: .data +auth_service: + enabled: "yes" + listen_addr: 0.0.0.0:5000 + tokens: + - "proxy,node:hello" +ssh_service: + enabled: "no" +proxy_service: + enabled: "no" diff --git a/examples/local-cluster/node/start.sh b/examples/local-cluster/node/start.sh new file mode 100755 index 00000000000..c12b94ed292 --- /dev/null +++ b/examples/local-cluster/node/start.sh @@ -0,0 +1,2 @@ +#!/bin/bash +teleport start -c teleport.yaml -d diff --git a/examples/local-cluster/node/teleport.yaml b/examples/local-cluster/node/teleport.yaml new file mode 100644 index 00000000000..799e2b22a40 --- /dev/null +++ b/examples/local-cluster/node/teleport.yaml @@ -0,0 +1,12 @@ +teleport: + nodename: graviton-node + auth_token: hello + auth_servers: + - 127.0.0.1:5000 + data_dir: .data +proxy_service: + enabled: "no" +auth_service: + enabled: "no" +ssh_service: + enabled: "yes" diff --git a/examples/local-cluster/proxy/start.sh b/examples/local-cluster/proxy/start.sh new file mode 100755 index 00000000000..c12b94ed292 --- /dev/null +++ b/examples/local-cluster/proxy/start.sh @@ -0,0 +1,2 @@ +#!/bin/bash +teleport start -c teleport.yaml -d diff --git a/examples/local-cluster/proxy/teleport.yaml b/examples/local-cluster/proxy/teleport.yaml new file mode 100644 index 00000000000..43dc5b734b9 --- /dev/null +++ b/examples/local-cluster/proxy/teleport.yaml @@ -0,0 +1,12 @@ +teleport: + nodename: graviton-proxy + auth_token: hello + auth_servers: + - 127.0.0.1:5000 + data_dir: .data +proxy_service: + enabled: "yes" +auth_service: + enabled: "no" +ssh_service: + enabled: "no" diff --git a/examples/local-cluster/tctl.sh b/examples/local-cluster/tctl.sh new file mode 100755 index 00000000000..a28501ffa1f --- /dev/null +++ b/examples/local-cluster/tctl.sh @@ -0,0 +1,2 @@ +#!/bin/bash +cd auth && tctl -c teleport.yaml $1 $2 $3 diff --git a/examples/systemd/README.md b/examples/systemd/README.md new file mode 100644 index 00000000000..24cbe760152 --- /dev/null +++ b/examples/systemd/README.md @@ -0,0 +1,3 @@ +# Systemd Service + +Sample configuration of `systemd` service file for Teleport diff --git a/examples/systemd/teleport.service b/examples/systemd/teleport.service new file mode 100644 index 00000000000..dfa959d9cfd --- /dev/null +++ b/examples/systemd/teleport.service @@ -0,0 +1,11 @@ +[Unit] +Description=Teleport SSH Service +After=network.target + +[Service] +Type=simple +Restart=always +ExecStart=/usr/local/bin/teleport start --config=/etc/teleport.yaml + +[Install] +WantedBy=multi-user.target