HomeGuidesAPI ReferenceGuidesMRT APIConfiguration API
GitHubAirheads Developer Community
Guides

Creating and Assigning Device Groups

📘

Source Code

You can find this playbook in the collection repository: examples/classic_groups.yml

This playbook creates Classic Central device groups — with their template and architecture properties — and assigns devices to them in the same task.

Prerequisites

  • A Classic Central account with API access enabled
  • A pre-generated Classic Central access_token
  • Device serial numbers for the devices you want to assign to a group

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)

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: Create Sites in HPE Aruba Networking Central
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Assign Devices to Sites in Classic HPE Aruba Networking Central
      arubanetworks.hpeanw_central.classic_groups:
        base_url: "{{ classic_base_url }}"
        access_token: "{{ classic_access_token }}"
        group_name: "Ansible-Device-Group-1"
        group_attributes:
          template_info:
            Wired: false
          group_properties:
            AllowedDevTypes:
              - AccessPoints
              - Gateways
              - Switches
            Architecture: AOS10
            ApNetworkRole: Standard
            GwNetworkRole: BranchGateway
            AllowedSwitchTypes:
              - AOS_CX
            NewCentral: true
        device_type: "ACCESS_POINT"
        devices:
          - "PHQSL1N5HB"
          - "PHQSL1N56K"
        state: merged
      register: sites_result

    - name: Create a device group for Switches
      arubanetworks.hpeanw_central.classic_groups:
        base_url: "{{ classic_base_url }}"
        access_token: "{{ classic_access_token }}"
        group_name: "Fabric2-Switches"
        group_attributes:
          template_info:
            Wired: false
          group_properties:
            AllowedDevTypes:
              - Switches
            AllowedSwitchTypes:
              - AOS_CX
            NewCentral: true
        device_type: "SWITCH"
        devices: []
        state: merged

Run it with:

ansible-playbook -i inventory.yml classic_groups.yml

Module Parameters

ParameterTypeRequiredDescription
group_namestrYesName of the device group
group_attributesdictWhen state: mergedGroup template/properties to create or update the group with
device_typestrYesACCESS_POINT, SWITCH, or GATEWAY — all devices must be this type
deviceslistYesSerial numbers to assign or unassign; pass [] to create a group without assigning devices
statestrNomerged (create/update group), deleted (delete group), assigned (default), or unassigned

Output

Each task reports result, containing the HTTP code, response msg, and headers from the underlying API call.

Troubleshooting

ProblemFix
Group creation failsCheck group_attributes.group_properties.AllowedDevTypes/AllowedSwitchTypes are valid for your architecture
Device assignment failsConfirm all devices share the same device_type and are already provisioned in Central
Deleting a group with devicesstate: deleted moves devices to the default group rather than failing — confirm that's the intended outcome

Support


Did this page help you?