|
1 | | -# vSphere cloud connection |
| 1 | +# Set up the vSphere cloud connection |
2 | 2 |
|
3 | | -Create or choose a vCenter user that can read the inventory you want Workbench to query. A read-only role at the vCenter, datacenter, cluster, or folder scope is usually enough for inventory tables. |
| 3 | +Connect Cloud Query to a vCenter inventory. This integration is read-only: it lists VMs, hosts, datastores, and networks. It does not power VMs on or off, change config, or install agents. |
4 | 4 |
|
5 | | -Use these values in the connection form: |
| 5 | +The form needs a **vCenter SDK endpoint**, a **vCenter SSO user**, and that user's **password**. |
6 | 6 |
|
7 | | -- **vCenter SDK endpoint:** `https://<vcenter-host>/sdk` |
8 | | -- **User:** a vCenter SSO user such as `administrator@vsphere.local`, or another account with read permissions |
9 | | -- **Password:** the password for that user |
10 | | -- **Allow unverified TLS certificates:** enable this only when vCenter uses an internal or self-signed certificate |
| 7 | +## Find the SDK endpoint |
| 8 | + |
| 9 | +The SOAP management API shares the vCenter hostname and HTTPS port with the vSphere Client. The difference is the **path**, not the port. |
| 10 | + |
| 11 | +| What | URL | |
| 12 | +|---|---| |
| 13 | +| vSphere Client (browser UI) | `https://<vcenter-host>/ui` | |
| 14 | +| SOAP SDK (this form) | `https://<vcenter-host>/sdk` | |
| 15 | +| Automation REST API | `https://<vcenter-host>/api` | |
| 16 | + |
| 17 | +1. Log in to the vSphere Client. |
| 18 | +2. Copy the hostname from the browser address bar. Ignore `/ui`, `/vsphere-client`, and any later path. |
| 19 | +3. Enter `https://<vcenter-host>/sdk`. |
| 20 | + |
| 21 | +Example: if the client is `https://vcenter.example.com/ui`, the SDK endpoint is `https://vcenter.example.com/sdk`. Default HTTPS port is **443**. Use `https://<vcenter-host>:<port>/sdk` only when vCenter listens on a non-default port. |
11 | 22 |
|
12 | | -You can verify that the SDK endpoint is exposed with: |
| 23 | +Do not use: |
| 24 | + |
| 25 | +- `/ui` or `/vsphere-client` (HTML, not SOAP) |
| 26 | +- `/api` or `/rest` (vSphere Automation REST, not the VIM SDK this connection uses) |
| 27 | +- An ESXi host URL, unless you only have a standalone host. Full inventory (datacenters, clusters, all VMs) requires **vCenter**. |
| 28 | + |
| 29 | +A hostname without a scheme or path (`vcenter.example.com`) also works; the client defaults to `https` and `/sdk`. Prefer the full `https://…/sdk` URL so it is obvious which API you are targeting. |
| 30 | + |
| 31 | +Verify the SDK is reachable: |
13 | 32 |
|
14 | 33 | ```bash |
15 | 34 | curl -k https://<vcenter-host>/sdk/vimServiceVersions.xml |
16 | 35 | ``` |
17 | 36 |
|
18 | | -The response should be XML listing the supported `urn:vim25` versions. |
| 37 | +The response should be XML listing `urn:vim25` versions, not an HTML login page. |
| 38 | + |
| 39 | +Enable **Allow unverified TLS certificates** only when vCenter uses an internal or self-signed certificate. |
| 40 | + |
| 41 | +## Create credentials |
| 42 | + |
| 43 | +Create a dedicated vCenter identity. Do not use the ESXi `root` user, and do not paste a vSphere Client session cookie. |
| 44 | + |
| 45 | +### Local SSO user (typical) |
| 46 | + |
| 47 | +1. In the vSphere Client, open **Menu → Administration → Single Sign On → Users and Groups**. |
| 48 | +2. Select the SSO domain (default `vsphere.local`). |
| 49 | +3. **Add User**. Choose a name such as `plural-cloud-query` and set a password. |
| 50 | + |
| 51 | +The form **User** value must include the domain: `plural-cloud-query@vsphere.local`. A bare username without `@vsphere.local` will fail SSO login. |
| 52 | + |
| 53 | +### Active Directory or other identity source |
| 54 | + |
| 55 | +If vCenter is joined to an identity source, create or pick a service account there, then use `user@domain.example` or `DOMAIN\user` as vCenter expects for that source. Still assign vCenter permissions below; directory membership alone does not grant inventory access. |
| 56 | + |
| 57 | +## Grant permissions for the APIs Cloud Query calls |
| 58 | + |
| 59 | +Cloud Query uses the Steampipe vSphere plugin. It authenticates with username/password, then: |
| 60 | + |
| 61 | +1. SOAP `POST https://<vcenter-host>/sdk` (VIM / vim25) |
| 62 | + - `SessionManager.Login` |
| 63 | + - `ViewManager.CreateContainerView` on the vCenter root folder |
| 64 | + - `ContainerView.Retrieve` for `VirtualMachine`, `HostSystem`, `Datastore`, and `Network` |
| 65 | +2. Automation REST (VM tags only, table `vsphere_vm`) |
| 66 | + - Session login on the vAPI endpoint |
| 67 | + - `cis/tagging` `GetAttachedTags` and `GetCategory` |
| 68 | + |
| 69 | +It does not call guest operations, power APIs, or write APIs. |
| 70 | + |
| 71 | +### Inventory (required) |
| 72 | + |
| 73 | +Use the built-in **Read-only** role. That role is exactly the system privileges needed to log in and read object properties: |
| 74 | + |
| 75 | +- `System.Anonymous` |
| 76 | +- `System.View` |
| 77 | +- `System.Read` |
| 78 | + |
| 79 | +Assign it so the user can see the objects you want queried: |
| 80 | + |
| 81 | +1. **Menu → Administration → Access Control → Global Permissions → Add**, or right-click the vCenter object (or a datacenter, cluster, or folder) → **Add Permission**. |
| 82 | +2. Select the SSO user. |
| 83 | +3. Role: **Read-only**. |
| 84 | +4. Enable **Propagate to children**. |
| 85 | + |
| 86 | +Without propagate, ContainerView returns nothing below the object you assigned. Scope the permission to a folder or cluster if the connection should not see the whole inventory. |
| 87 | + |
| 88 | +Do not grant Administrator, Virtual machine **Power user**, or other write roles. |
| 89 | + |
| 90 | +### Tags (needed for `vsphere_vm.tags`) |
| 91 | + |
| 92 | +vSphere tags are global objects, not children of a VM. Inventory Read-only on a VM does not include tag reads. |
| 93 | + |
| 94 | +Assign **Read-only** as a **Global Permission** (with propagate) so the user can call tagging REST. If tagging REST fails, VM inventory queries can fail entirely because tag lookup runs as part of listing VMs. |
| 95 | + |
| 96 | +You do not need **vSphere Tagging → Create / Edit / Delete** or **Assign or Unassign vSphere Tag**. |
| 97 | + |
| 98 | +## Complete the configuration |
| 99 | + |
| 100 | +- **vCenter SDK endpoint:** `https://<vcenter-host>/sdk` |
| 101 | +- **User:** SSO principal, for example `plural-cloud-query@vsphere.local` |
| 102 | +- **Password:** that user's password |
| 103 | +- **Allow unverified TLS certificates:** only for internal or self-signed vCenter certs |
0 commit comments