HomeGuidesAPI ReferenceGuidesMRT APIConfiguration API
GitHubAirheads Developer Community
Guides

Classic Central API Demo

📘

Source Code

You 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

  1. Install the collection from Ansible Galaxy:
ansible-galaxy collection install arubanetworks.hpeanw_central
  1. Install the pycentral v2 SDK, which the collection depends on:
pip3 install --pre pycentral

This 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_result

Run it with:

ansible-playbook -i inventory.yml classic_api_demo.yml

Module Parameters

ParameterTypeRequiredDescription
base_urlstrYesClassic Central base URL
access_tokenstrYesPre-generated OAuth token — this module does not generate or refresh tokens
methodstrNoHTTP method (GET, POST, PUT, DELETE, PATCH); default GET
pathstrYesAPI endpoint path, without the base URL
datadictNoRequest body for POST/PUT/PATCH
paramsdictNoURL query parameters

Output

The sites_result variable registered from the task contains:

FieldDescription
codeHTTP response status code
msgResponse body (dict or string, depending on the API)
headersResponse headers

Troubleshooting

ProblemFix
401/403 responseThe access_token has expired or lacks permission — generate a new one
404 responseConfirm path matches a valid Classic Central endpoint
Wrong region errorsConfirm base_url matches the API Gateway domain for your Classic Central cluster

Support


Did this page help you?