Getting Started with Ansible and Central
Ansible is an open-source automation framework and orchestration tool, owned by Red Hat, that automates provisioning, configuration management, and application deployment. In 2019, HPE Aruba Networking became an official Ansible partner, we are continuously dedicated to bridging the gap between programmer and network engineer through our suite of supported collections and workflows.
What is the Central Ansible Collection?
The HPE Aruba Networking Central Ansible Collection lets you automate HPE Aruba Networking Central and the HPE GreenLake Platform (GLP) using Ansible modules and plugins. You can use Ansible playbooks to:
- Authenticate and manage API sessions across multiple platforms
- Query devices, sites, and subscriptions
- Manage supported configuration profiles
- Troubleshoot and automate repeatable workflows
Beta Notice
NoteThis collection is currently in beta / pre-release. Features and behavior may change before general availability. Use in test or non-production environments while validating workflows.
Key Benefits
- Platform coverage: Supports New Central, GLP, and Classic Central modules.
- Built-in token workflows: Dedicated token modules (
central_token,glp_token,unified_token,msp_token) generate OAuth tokens at play start, or passclient_id/client_secretdirectly to each module for automatic token management. - Idempotent configuration: Profile and site modules support
merged,replaced, anddeletedstates and return adiffof what changed, making playbooks safe to re-run. - Flexible execution: Run direct API calls with generic modules or use purpose-built feature-specific modules.
- Dynamic inventory support: Automatically discover and group Central-managed devices by site, device type, model, and status.
Setting Up the Environment
Ansible is an agentless automation tool that runs from a control node (Linux or macOS). For this collection, modules execute locally and call Central/GLP APIs.
Set this in your inventory for localhost-based execution:
all:
hosts:
localhost:
ansible_connection: localRequirements
- Ansible 2.19 or lower
- Python 3.6 or later
- PyCentral v2 SDK
Install PyCentral:
pip3 install --pre pycentralIf Ansible is not installed yet, use the official installation guide:
If you are on Ubuntu and need a quick install path:
sudo apt update
sudo apt -y upgrade
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt-get install ansibleValidate your Ansible installation:
ansible --version
ansible localhost -m pingInstall the Collection
Install from Ansible Galaxy:
ansible-galaxy collection install arubanetworks.hpeanw_centralOr install the bundled tarball from this repository:
ansible-galaxy collection install arubanetworks-hpeanw_central-2.0.0-beta.tar.gz -fValidate installation:
ansible-galaxy collection list | grep hpeanw_centralTwo Ways to Use the Collection
There are two common usage patterns. Start simple, then move to specialized modules as needed.
-
Generic API modules (
central_api,classic_api,glp_api):
Call API endpoints directly when you are exploring or need an endpoint not yet wrapped by a specific module. -
Purpose-built modules (
*_info,*_sites,*_profiles,*_token, etc.):
Use these for common workflows with cleaner parameters and less playbook boilerplate.
Authentication
Each module authenticates against one of three platforms:
| Platform | Requires base_url? | Credentials | Auto-refresh |
|---|---|---|---|
| Central | Yes | client_id/client_secret or access_token | Yes, when client credentials are provided |
| GLP | No | client_id/client_secret or access_token | Yes, when client credentials are provided |
| Classic Central | Yes | access_token only | No — tokens must be regenerated manually |
Two authentication approaches
Direct credentials (recommended): Pass client_id and client_secret directly to each module. The module handles token generation automatically, so tokens never expire mid-playbook. This is best for most playbooks and any run longer than 15 minutes (GLP tokens expire after 15 minutes; Central tokens after 2 hours).
Token module: Generate a token once with a *_token module (central_token, glp_token, unified_token, msp_token) and pass access_token to subsequent tasks. Best for short playbooks where you want a single token exchange at play start. Use unified_token with a workspace_id when your playbook calls both GLP and Central APIs.
Security: Always set
no_log: trueon tasks that handle credentials or tokens. Store secrets in Ansible Vault rather than plain text.
Quick Start Example (New Central)
1. Create an inventory
# inventory.yml
all:
hosts:
localhost:
ansible_connection: local
central_base_url: https://us4.api.central.arubanetworks.com
central_client_id: your_client_id
central_client_secret: your_client_secret2. Create a playbook
# central_quickstart.yml
- name: Central quickstart
hosts: localhost
gather_facts: no
tasks:
- name: Create OAuth token from Central
arubanetworks.hpeanw_central.central_token:
base_url: "{{ central_base_url }}"
client_id: "{{ central_client_id }}"
client_secret: "{{ central_client_secret }}"
no_log: true
register: token_result
- name: Fetch devices from Central
arubanetworks.hpeanw_central.central_api:
base_url: "{{ central_base_url }}"
access_token: "{{ token_result['access_token'] }}"
method: GET
path: "/network-config/v1alpha1/devices"
register: devices_result
- name: Show API result
ansible.builtin.debug:
var: devices_result3. Run the playbook
ansible-playbook central_quickstart.yml -i inventory.ymlDynamic Inventory Plugin (Optional)
Use the central_inventory plugin to auto-discover devices and build groups.
# central_inventory.yml
plugin: arubanetworks.hpeanw_central.central_inventory
central_base_url: https://us4.api.central.arubanetworks.com
central_client_id: your_client_id
central_client_secret: your_client_secret
# Optional
output_file: ./central_devices_inventory.yml
groups:
- site
- device_type
- modelTest it:
ansible-inventory -i central_inventory.yml --listNext Steps
| Topic | Where to go next |
|---|---|
| Authentication | Authentication |
| Module docs | docs/ directory in this repository |
| Inventory plugin details | [docs/central_inventory_plugin.mdcccccbulilvbuunrvcgidbgvhjrigunchbdhcrdkgdgb |
| ](https://github.com/aruba/aruba-central-ansible-collection/blob/v2-beta/docs/central_inventory_plugin.md) | |
| Examples | examples/ directory |
| Central API module | docs/central_api.md |
| Token modules | docs/central_token.md, docs/glp_token.md, docs/unified_token.md |
| MSP automation | MSP Automation |
For issue reporting and updates, use the repository issue tracker and Ansible Galaxy listing for this collection.
Updated 4 months ago