node.hostname.get
Get the system hostname and agent labels.
Usage
task := plan.TaskFunc("get-hostname",
func(
ctx context.Context,
c *client.Client,
) (*orchestrator.Result, error) {
resp, err := c.Node.Hostname(ctx, "_any")
if err != nil {
return nil, err
}
return orchestrator.CollectionResult(
resp.Data,
func(r client.HostnameResult) orchestrator.HostResult {
return orchestrator.HostResult{
Hostname: r.Hostname,
Changed: r.Changed,
Error: r.Error,
}
},
), nil
},
)
Parameters
None.
Target
Accepts any valid target: _any, _all, a hostname, or a label selector
(key:value).
Idempotency
Read-only. Never modifies state. Always returns Changed: false.
Permissions
Requires node:read permission.
Example
See
examples/sdk/orchestrator/operations/node-hostname.go
for a complete working example.