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
8 changes: 7 additions & 1 deletion lib/web/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ import (
"github.com/gravitational/teleport/lib/web/scripts"
)

const insecureParamName = "insecure"
const (
insecureParamName = "insecure"
groupParamName = "group"
)

// installScriptHandle handles calls for "/scripts/install.sh" and responds with a bash script installing Teleport
// by downloading and running `teleport-update`. This installation script does not start the agent, join it,
Expand All @@ -62,6 +65,9 @@ func (h *Handler) installScriptHandle(w http.ResponseWriter, r *http.Request, pa
}
opts.Insecure = v
}
if group := r.URL.Query().Get(groupParamName); group != "" {
opts.Group = group
}

script, err := scripts.GetInstallScript(r.Context(), opts)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions lib/web/scripts/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ type InstallScriptOptions struct {
// the artifacts from the CDN.
// The agent install in insecure mode will not be able to automatically update.
Insecure bool
// Group is the group for agent installation used by 'teleport-update enable' command.
// Ignored by legacy script.
Group string
}

// Check validates that the minimal options are set.
Expand Down Expand Up @@ -138,6 +141,9 @@ func (o *InstallScriptOptions) oneOffParams() (params oneoff.OneOffScriptParams)
}

successMessage := "Teleport successfully installed."
if o.Group != "" {
args = append(args, "--group", shsprintf.EscapeDefaultContext(o.Group))
}
if o.Insecure {
args = append(args, "--insecure")
successMessage += " --insecure was used during installation, automatic updates will not work unless the Proxy Service presents a certificate trusted by the system."
Expand Down
18 changes: 18 additions & 0 deletions lib/web/scripts/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ func TestGetInstallScript(t *testing.T) {
require.Contains(t, script, "packageSuffix='bin.tar.gz'")
},
},
{
name: "Oneoff install with group",
opts: InstallScriptOptions{
AutoupdateStyle: UpdaterBinaryAutoupdate,
TeleportVersion: testVersion,
ProxyAddr: testProxyAddr,
TeleportFlavor: types.PackageNameOSS,
Group: "development",
},
assertFn: func(t *testing.T, script string) {
require.Contains(t, script, "entrypoint='teleport-update'")
require.Contains(t, script, fmt.Sprintf("teleportVersion='v%s'", testVersion))
require.Contains(t, script, fmt.Sprintf("teleportFlavor='%s'", types.PackageNameOSS))
require.Contains(t, script, fmt.Sprintf("cdnBaseURL='%s'", teleportassets.CDNBaseURL()))
require.Contains(t, script, fmt.Sprintf("entrypointArgs='enable --proxy %s --group development'", testProxyAddr))
require.Contains(t, script, "packageSuffix='bin.tar.gz'")
},
},
{
name: "Oneoff install custom CDN",
opts: InstallScriptOptions{
Expand Down
Loading