Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion docs/pages/reference/cli/teleport.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ we recommend using a [configuration file](../config.mdx) in production.
| `--ca-pin` | none | **string** `sha256:<hash>` | set CA pin to validate the Auth Server. Generated by `tctl status` |
| `--nodename` | value returned by the `hostname` command on the machine | **string** | assigns an alternative name for the node which can be used by clients to log in. |
| `-c, --config` | `/etc/teleport.yaml` | **string** `.yaml` filepath | starts services with config specified in the YAML file, overrides CLI flags if set |
| `--apply-on-startup` | none | **string** `.yaml` filepath | On startup, always apply resources described in the file at the given path. Only supports the following types: `token`. |
| `--apply-on-startup` | none | **string** `.yaml` filepath | On startup, always apply resources described in the file at the given path. Only supports the following kinds: `token`, `cluster-auth-preference`, `cluster-networking-config`. |
| `--bootstrap` | none | **string** `.yaml` filepath | bootstrap configured YAML resources {/* TODO link how to configure this file */} |
| `--labels` | none | **string** comma-separated list | assigns a set of labels to a node, for example env=dev,app=web. See the explanation of labeling mechanism in the [Labeling Nodes](../../management/admin/labels.mdx) section. |
| `--insecure` | none | none | disable certificate validation on Proxy Service, validation still occurs on Auth Service. |
Expand Down
4 changes: 4 additions & 0 deletions lib/auth/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,10 @@ func applyResources(ctx context.Context, service *Services, resources []types.Re
switch r := resource.(type) {
case types.ProvisionToken:
err = service.Provisioner.UpsertToken(ctx, r)
case types.ClusterNetworkingConfig:
err = service.ClusterConfiguration.SetClusterNetworkingConfig(ctx, r)
case types.AuthPreference:
err = service.ClusterConfiguration.SetAuthPreference(ctx, r)
default:
return trace.NotImplemented("cannot apply resource of type %T", resource)
}
Expand Down
32 changes: 32 additions & 0 deletions lib/auth/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1286,13 +1286,31 @@ spec:
github:
allow:
- repository: gravitational/example`
clusterNetworkingConfYAML = `
kind: cluster_networking_config
metadata:
name: cluster-networking-config
spec:
proxy_listener_mode: 1
`
authPrefYAML = `
kind: cluster_auth_preference
metadata:
name: cluster-auth-preference
spec:
second_factor: off
type: local
version: v2
`
)

func TestInit_ApplyOnStartup(t *testing.T) {
t.Parallel()

user := resourceFromYAML(t, userYAML).(types.User)
token := resourceFromYAML(t, tokenYAML).(types.ProvisionToken)
clusterNetworkingConfig := resourceFromYAML(t, clusterNetworkingConfYAML).(types.ClusterNetworkingConfig)
authPref := resourceFromYAML(t, authPrefYAML).(types.AuthPreference)

tests := []struct {
name string
Expand All @@ -1313,6 +1331,20 @@ func TestInit_ApplyOnStartup(t *testing.T) {
},
assertError: require.NoError,
},
{
name: "Apply ClusterNetworkingConfig",
modifyConfig: func(cfg *InitConfig) {
cfg.ApplyOnStartupResources = append(cfg.ApplyOnStartupResources, clusterNetworkingConfig)
},
assertError: require.NoError,
},
{
name: "Apply AuthPreference",
modifyConfig: func(cfg *InitConfig) {
cfg.ApplyOnStartupResources = append(cfg.ApplyOnStartupResources, authPref)
},
assertError: require.NoError,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tool/teleport/common/teleport.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
fmt.Sprintf("Path to a configuration file [%v]", defaults.ConfigFilePath)).
Short('c').ExistingFileVar(&ccf.ConfigFile)
start.Flag("apply-on-startup",
fmt.Sprintf("Path to a non-empty YAML file containing resources to apply on startup. Works on initialized clusters, unlike --bootstrap. Only supports the following types: %s.", types.KindToken)).
fmt.Sprintf("Path to a non-empty YAML file containing resources to apply on startup. Works on initialized clusters, unlike --bootstrap. Only supports the following types: %s, %s, %s.", types.KindToken, types.KindClusterNetworkingConfig, types.KindClusterAuthPreference)).
ExistingFileVar(&ccf.ApplyOnStartupFile)
start.Flag("bootstrap",
"Path to a non-empty YAML file containing bootstrap resources (ignored if already initialized)").ExistingFileVar(&ccf.BootstrapFile)
Expand Down