Classic Central API Demo
Source CodeYou can find this playbook in the collection repository:
examples/classic_api_demo.yml
This playbook demonstrates calling the Classic Central REST API directly with the classic_api module. Unlike New Central and GLP, Classic Central does not support automatic token generation or refresh — a valid, pre-generated access_token must be provided for every call.
Prerequisites
- A Classic Central account with API access enabled
- A pre-generated Classic Central
access_token
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)
For API operations in Classic HPE Aruba Networking Central:
all:
hosts:
localhost:
ansible_connection: local # Do not change
classic_base_url: <classic-central-api-base-url>
classic_access_token: <classic-central-access-token>
Important Links
Execution
- name: Demo Classic HPE Aruba Networking Central API Calls
hosts: localhost
gather_facts: no
tasks:
- name: Get Sites from Classic Central
arubanetworks.hpeanw_central.classic_api:
base_url: "{{ classic_base_url }}"
access_token: "{{ classic_access_token }}"
method: GET
path: "/central/v2/sites"
register: sites_result
- debug:
var: sites_resultRun it with:
ansible-playbook -i inventory.yml classic_api_demo.ymlModule Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base_url | str | Yes | Classic Central base URL |
access_token | str | Yes | Pre-generated OAuth token — this module does not generate or refresh tokens |
method | str | No | HTTP method (GET, POST, PUT, DELETE, PATCH); default GET |
path | str | Yes | API endpoint path, without the base URL |
data | dict | No | Request body for POST/PUT/PATCH |
params | dict | No | URL query parameters |
Output
The sites_result variable registered from the task contains:
| Field | Description |
|---|---|
code | HTTP response status code |
msg | Response body (dict or string, depending on the API) |
headers | Response headers |
Troubleshooting
| Problem | Fix |
|---|---|
| 401/403 response | The access_token has expired or lacks permission — generate a new one |
| 404 response | Confirm path matches a valid Classic Central endpoint |
| Wrong region errors | Confirm base_url matches the API Gateway domain for your Classic Central cluster |
Support
- Automation Team: [email protected]
- Collection Issues: GitHub Issues
Updated 4 months ago
Did this page help you?