Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add join-method flag to teleport node configure #13097

Merged
merged 3 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/pages/setup/reference/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ teleport:
# auth_token: /var/lib/teleport/tokenjoin
auth_token: xxxx-token-xxxx

# join_params are parameters to set when joining a cluster via
# EC2, IAM or a token.
#
# EC2 join method documentation:
# https://goteleport.com/docs/setup/guides/joining-nodes-aws-ec2/
# IAM join method documentation:
# https://goteleport.com/docs/setup/guides/joining-nodes-aws-iam/
join_params:
# join_method when set to "token", is equivalent to using auth_token.
join_method: "token"|"ec2"|"iam"
# When join_method is "token", token_name is either the
# token or the path to a file containing the token.
#
# If join_method is "iam" or "ec2", token_name will be will be
# the name of the joining token resource, e.g., "ec2-token" or
# "iam-token" as created in the Joining Nodes via EC2 or IAM
# guides.
token_name: "token-name"
lxea marked this conversation as resolved.
Show resolved Hide resolved

# Optional CA pin of the auth server. This enables a more secure way of
# adding new nodes to a cluster. See "Adding Nodes to the Cluster"
# (https://goteleport.com/docs/admin-guide/#adding-nodes-to-the-cluster).
Expand Down
8 changes: 7 additions & 1 deletion lib/config/fileconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ type SampleFlags struct {
AppURI string
// NodeLabels is list of labels in the format `foo=bar,baz=bax` to add to newly created nodes.
NodeLabels string
// JoinMethod is the method that will be used to join the cluster, either "token", "iam" or "ec2"
JoinMethod string
}

// MakeSampleFileConfig returns a sample config to start
Expand Down Expand Up @@ -198,7 +200,11 @@ func MakeSampleFileConfig(flags SampleFlags) (fc *FileConfig, err error) {
g.DataDir = defaults.DataDir
}

g.AuthToken = flags.AuthToken
g.JoinParams = JoinParams{
TokenName: flags.AuthToken,
Method: types.JoinMethod(flags.JoinMethod),
}

if flags.AuthServer != "" {
g.AuthServers = []string{flags.AuthServer}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/config/fileconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,12 @@ func TestMakeSampleFileConfig(t *testing.T) {

t.Run("Token", func(t *testing.T) {
fc, err := MakeSampleFileConfig(SampleFlags{
AuthToken: "auth-token",
AuthToken: "auth-token",
JoinMethod: "token",
})
require.NoError(t, err)
require.Equal(t, "auth-token", fc.AuthToken)
require.Equal(t, "auth-token", fc.JoinParams.TokenName)
require.Equal(t, types.JoinMethodToken, fc.JoinParams.Method)
})

t.Run("App name and URI", func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions tool/teleport/common/teleport.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
dumpNodeConfigure.Flag("token", "Invitation token to register with an auth server.").StringVar(&dumpFlags.AuthToken)
dumpNodeConfigure.Flag("auth-server", "Address of the auth server.").StringVar(&dumpFlags.AuthServer)
dumpNodeConfigure.Flag("labels", "Comma-separated list of labels to add to newly created nodes ex) env=staging,cloud=aws.").StringVar(&dumpFlags.NodeLabels)
dumpNodeConfigure.Flag("join-method", "Method to use to join the cluster (token, iam, ec2)").Default("token").EnumVar(&dumpFlags.JoinMethod, "token", "iam", "ec2")

// parse CLI commands+flags:
utils.UpdateAppUsageTemplate(app, options.Args)
Expand Down