The central_inventory plugin is an Ansible dynamic inventory plugin that automatically discovers and organizes network devices from HPE Aruba Networking Central into structured Ansible inventory groups. This eliminates the need to manually maintain inventory files and ensures your Ansible inventory is always synchronized with your actual network infrastructure.
The plugin connects to HPE Aruba Networking Central's API and:
- Fetches all network devices from your Central account
- Organizes devices into logical groups based on attributes like:
- Site location
- Device type (Switch, Gateway, Access Point)
- Device model
- Provisioning status
- Device group assignment
- Extracts device metadata as host variables (IP addresses, serial numbers, firmware versions, etc.)
- Stores Central credentials at the inventory level for reuse in playbooks
- Optionally exports the inventory to a static YAML file
plugin: arubanetworks.hpeanw_central.central_inventory
central_base_url: https://internal.api.central.arubanetworks.com
central_client_id: your_client_id
central_client_secret: your_client_secretplugin: arubanetworks.hpeanw_central.central_inventory
# Authentication (choose one method)
central_base_url: https://internal.api.central.arubanetworks.com
central_access_token: your_access_token # Method 1: Direct token
# OR
central_client_id: your_client_id # Method 2: OAuth credentials
central_client_secret: your_client_secret
# Grouping options (default: ['site', 'device_type'])
groups:
- site # Groups by siteName
- device_type # Groups by deviceType (SWITCH, GATEWAY, ACCESS_POINT)
- model # Groups by device model
- status # Groups by status (ONLINE, OFFLINE)
- group # Groups by deviceGroupName
# Filtering options
filters:
device_type:
- ACCESS_POINT
- SWITCH
status:
- ONLINE
site:
- Building_A
- ADL-Collin
# Export to static file
output_file: /path/to/central_devices_inventory.yml
# Custom host variables using Jinja2
compose:
ansible_host: ipv4
is_online: status == 'ONLINE'
# Dynamic grouping
keyed_groups:
- key: model
prefix: model
- key: softwareVersion
prefix: version
separator: '_'- Token Reuse: If
output_fileexists, the plugin reads the storedcentral_access_tokenand reuses it - New Connection: If no token exists or is expired, it authenticates using:
- Provided
central_access_token, OR - OAuth with
central_client_idandcentral_client_secret
- Provided
- Token Storage: The active token is stored in the output file for subsequent runs
- Connects to Central's Monitoring API
- Fetches all devices using
MonitoringDevices.get_all_device_inventory() - Applies any configured filters
- Creates inventory groups based on device attributes
- Assigns devices to appropriate groups
- Exports to YAML if
output_fileis specified
The plugin generates a hierarchical inventory with:
all:
vars: # Shared variables for all hosts
central_base_url: ...
central_access_token: ...
central_client_id: ...
central_client_secret: ...
hosts: # All discovered devices
<serialNumber>: # Device serial as hostname
<device_attributes>
children: # Dynamic groups
site_<site_name>: # Site-based groups
hosts: ...
type_<device_type>: # Type-based groups
hosts: ...
model_<model>: # Model-based groups
hosts: ...Based on the generated inventory, here's what you can expect:
all:
vars:
central_base_url: https://internal.api.central.arubanetworks.com
central_access_token: eyJhbGciOiJSUzI1NiIsImtpZCI6IjE2...
central_client_id: e8e333303-f720-446a-8034-6bbf2f39039c
central_client_secret: 4f722244464d416fac41f6b7ebc00ca5Each device becomes a host with comprehensive metadata:
all:
hosts:
CNSKKLB00C: # Serial number as hostname
status: ONLINE
deviceType: GATEWAY
model: 9004-US
deviceName: Aruba9004_63_89_1E
macAddress: f0:1a:a0:63:89:1e
ipv4: 0.0.0.0
siteName: LSV-WPA3-PSK-Site
siteId: '49171617624236032'
deviceGroupName: ADL-Lucas
softwareVersion: 10.7.2.2_94048
firmwareVersion: 10.7.2.2_94048
tier: ADVANCE_70XX
persona: Mobility Gateway
deviceFunction: Mobility GW
isProvisioned: 'Yes'
inventory_hostname: CNSKKLB00C
group_names:
- site_lsv_wpa3_psk_site
- type_gatewaySite-Based Groups:
all:
children:
site_building_a:
hosts:
CNSKKLB0DW: # Gateway
VNQ7KZD4P5: # Access Point
site_adl_collin:
hosts:
TW3BLZB0V5: # Switch
VNQ7KZD4JB: # Access PointType-Based Groups:
all:
children:
type_switch:
hosts:
TW3BLZB0VB:
TW3BLZB0V5:
SG38LMY056:
SG38LMY07R:
type_gateway:
hosts:
CNSKKLB00C:
CNSKKLB09T:
CNSKKLB0DW:
type_access_point:
hosts:
VNQ7KZD4MS:
VNQ7KZD4P5:
VNQ7KZD4J7:Each device includes the following variables:
serialNumber- Device serial numbermacAddress- Device MAC addressdeviceName- Friendly nameid- Unique device IDscopeId- Device scope identifier
ipv4- IPv4 address (null if unprovisioned)status- Current status (ONLINE, OFFLINE, null)siteName- Assigned site namesiteId- Site identifier
deviceType- SWITCH, GATEWAY, ACCESS_POINTdeviceFunction- Functional role (e.g., "Mobility GW", "Campus AP")persona- Device persona (e.g., "Access Switch", "Campus Access Point")model- Device model (e.g., "6200F", "9004-US", "AP-615-US")partNumber- Part numbertier- Subscription tier (e.g., "ADVANCED_SWITCH_6200", "ADVANCE_70XX")
softwareVersion- Installed software versionfirmwareVersion- Firmware versionisProvisioned- "Yes" or "No"deployment- Deployment type (Standalone, Campus AP, etc.)
deviceGroupName- Assigned device groupdeviceGroupId- Group identifierrole- Device role (if assigned)stackId- Stack ID (null for non-stacked devices)
Target specific device types:
ansible-playbook configure_switches.yml -i central_inventory.yml --limit type_switchDeploy configurations to specific sites:
ansible-playbook deploy.yml -i central_inventory.yml --limit site_building_aTarget only online devices:
# In your inventory config
filters:
status:
- ONLINEThe plugin stores credentials at the all group level, making them available in your playbooks:
- name: Make Central API call
arubanetworks.hpeanw_central.central_api:
base_url: "{{ central_base_url }}"
access_token: "{{ central_access_token }}"
endpoint: /monitoring/v2/devicesGenerate reports on device status, versions, and provisioning:
ansible-inventory -i central_inventory.yml --list > device_audit.jsonThe plugin sanitizes group names to be Ansible-compatible:
- Spaces → underscores (
Building A→building_a) - Hyphens → underscores (
LSV-WPA3→lsv_wpa3) - Lowercase conversion
- Numeric prefixes get
g_prefix (6300→g_6300)
Group Prefixes:
site_- Site-based groupstype_- Device type groupsmodel_- Model-based groupsstatus_- Status-based groupsgroup_- Device group-based groups
- Verify
central_base_urlmatches your region - Check client ID/secret or token validity