Generating a Unified Token for GLP
Source CodeYou can find this playbook in the collection repository:
examples/unified_token.yml
This playbook generates an OAuth token from unified credentials and uses it to call GLP. Unified credentials are useful when a workflow needs GLP only, or both GLP and New Central, from a single set of client credentials scoped to a GreenLake workspace.
Prerequisites
- A GreenLake workspace with API access enabled
- A
client_id,client_secret, andworkspace_idfor the workspace
Installation
- Install the collection from Ansible Galaxy:
ansible-galaxy collection install arubanetworks.hpeanw_central- Install the
pycentralv2 SDK, which the collection depends on:
pip3 install --pre pycentralThis workflow is tested on collection version 2.1.1-beta. Please check compatibility before executing on older/newer versions as there may be changes.
Configuration
Credentials Configuration (inventory.yml)
all:
hosts:
localhost:
ansible_connection: local # Do not change
glp_client_id: <glp-client-id>
glp_client_secret: <glp-client-secret>
glp_workspace_id: <glp-workspace-id>
Important Links
Execution
- name: Generate unified token and use with GLP API
hosts: localhost
gather_facts: no
tasks:
- name: Create unified OAuth Token for GLP only
arubanetworks.hpeanw_central.unified_token:
client_id: "{{ glp_client_id }}"
client_secret: "{{ glp_client_secret }}"
workspace_id: "{{ glp_workspace_id }}"
register: token_result
no_log: true
- name: Get GLP devices with generated unified token
arubanetworks.hpeanw_central.glp_devices_info:
access_token: "{{ token_result['access_token'] }}"
register: devices_result
- debug:
var: devices_resultRun it with:
ansible-playbook -i inventory.yml unified_token.ymlModule Parameters (unified_token)
unified_token)| Parameter | Type | Required | Description |
|---|---|---|---|
client_id | str | Yes | Client ID for the GLP workspace |
client_secret | str | Yes | Client secret for the GLP workspace |
workspace_id | str | Yes | GreenLake workspace ID associated with the credentials |
Output
token_result contains access_token — the generated OAuth token, usable with any GLP module in the same playbook run.
Troubleshooting
| Problem | Fix |
|---|---|
| 401/403 on token generation | Verify client_id/client_secret are valid and scoped to workspace_id |
| Workspace not found | Confirm workspace_id matches the GreenLake workspace the credentials belong to |
| Token works for GLP but not Central | Unified tokens generated this way are GLP-scoped; use central_token for New Central calls |
Support
- Automation Team: [email protected]
- Collection Issues: GitHub Issues
Updated 4 months ago
Did this page help you?