Skip to content

Commit

Permalink
[v16] Omit control plane instances from inventory list (#43779)
Browse files Browse the repository at this point in the history
* Omit control plane instances from inventory list

* Update docs about tctl inventory ls

* List control plane if services is explicitly requested
  • Loading branch information
bernardjkim authored Jul 3, 2024
1 parent 0055712 commit a6d2c45
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 0 additions & 4 deletions docs/pages/upgrading/automatic-agent-updates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ Server ID Hostname Services Version Upgrader
...
```

Note that the `inventory ls` command will also list `teleport-auth` and
`teleport-proxy` services. If you use managed Teleport Enterprise, the Teleport
team updates these services automatically.

## Step 3/4. Enroll agents on Linux servers in automatic updates

1. For each agent ID returned by the `tctl inventory ls` command, copy the ID
Expand Down
4 changes: 0 additions & 4 deletions docs/pages/upgrading/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@ self-hosted clusters, as well as all Teleport agents.
...
```

Note that the `inventory ls` command will also list `teleport-auth` and
`teleport-proxy` services. These services are managed by the Teleport team, and
updates will be performed automatically.

1. For each agent ID returned by the `tctl inventory ls` command, copy the ID
and run the following `tctl` command to access the host via `tsh`:

Expand Down
15 changes: 15 additions & 0 deletions tool/tctl/common/inventory_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,20 @@ func printHierarchicalData(data map[string]any, indent string, depth int) {
func (c *InventoryCommand) List(ctx context.Context, client *authclient.Client) error {
var services []types.SystemRole
var err error
var omitControlPlane bool
if c.services != "" {
services, err = types.ParseTeleportRoles(c.services)
if err != nil {
return trace.Wrap(err)
}
} else {
resp, err := client.Ping(ctx)
if err != nil {
return trace.Wrap(err)
}
omitControlPlane = resp.GetServerFeatures().GetCloud()
}

upgrader := c.upgrader
var noUpgrader bool
if upgrader == "none" {
Expand All @@ -205,6 +213,13 @@ func (c *InventoryCommand) List(ctx context.Context, client *authclient.Client)
table := asciitable.MakeTable([]string{"Server ID", "Hostname", "Services", "Agent Version", "Upgrader", "Upgrader Version"})
for instances.Next() {
instance := instances.Item()

// The auth and proxy services should be omitted from the inventory list
// on Managed Teleport Enterprise (Cloud-Hosted) instances.
if omitControlPlane && (instance.HasService(types.RoleAuth) || instance.HasService(types.RoleProxy)) {
continue
}

services := make([]string, 0, len(instance.GetServices()))
for _, s := range instance.GetServices() {
services = append(services, string(s))
Expand Down

0 comments on commit a6d2c45

Please sign in to comment.