HomeGuidesAPI ReferenceGuidesMRT APIConfiguration API
GitHubAirheads Developer Community
Guides

Creating Library Configuration Profiles

📘

Source Code

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

This playbook creates several library configuration profiles in New Central that can later be assigned to sites or devices: a VLAN profile, a default gateway profile, and multiple VRF profiles.

Prerequisites

  • A New Central account with API access enabled
  • A client_id and client_secret for New Central

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 HPE Aruba Networking Central:

all:
  hosts:
    localhost:
      ansible_connection: local # Do not change
      central_base_url: <central-api-base-url>
      central_client_id: <new-central-client-id>
      central_client_secret: <new-central-client-secret>
📘

Important Links

Execution

- name: Create Library Profiles in HPE Aruba Networking Central
  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 }}"
      register: token_result

    - set_fact:
        central_access_token: "{{ token_result['access_token'] }}"

    - name: Create a new Library VLAN profile
      arubanetworks.hpeanw_central.central_profiles:
        base_url: "{{ central_base_url }}"
        access_token: "{{ central_access_token }}"
        name: 100
        path: "layer2-vlan"
        config_dict:
          vlan: 100
          name: "Corp-VLAN"
          description: "Corporate VLAN for main office"
        state: merged

    - name: Create Library Default Gateway
      arubanetworks.hpeanw_central.central_profiles:
        base_url: "{{ central_base_url }}"
        access_token: "{{ central_access_token }}"
        name: rsvl-default-gateway
        path: static-route
        state: merged
        config_dict:
          default-gateway:
            - dg-name: rsvl-default-gateway
              forwarding-type: "NEXTHOP"
              ipv4-address: "192.168.0.1"

    - name: Create Library VRFs
      arubanetworks.hpeanw_central.central_profiles:
        base_url: "{{ central_base_url }}"
        access_token: "{{ central_access_token }}"
        name: "{{ item }}"
        path: vrfs
        state: merged
        config_dict:
          name: "{{ item }}"
      loop:
        - rsvl-corp
        - rsvl-guest

Run it with:

ansible-playbook -i inventory.yml central_profiles_demo.yml

Module Parameters (central_profiles)

ParameterTypeRequiredDescription
pathstrYesEndpoint of the profile type, relative to /network-config/v1alpha1/
namestrNoProfile identifier; recommended for idempotency on updates/deletes
config_dictdictYesProfile configuration payload
statestrNomerged (default), replaced, or deleted

Output

Each central_profiles task reports:

FieldDescription
changedtrue if the profile was created, modified, or deleted
msgSuccess message, or error details if the operation failed
resultResponse details; includes a diff of old_value/new_value when state: merged causes an update

Troubleshooting

ProblemFix
Profile already exists errorsSet state: merged (default) instead of creating a new profile every run
config_dict schema errorsCheck the profile type's API reference for required fields at that path
VRF/gateway name collisionsVRF and gateway name values must be unique per profile type in the library

Support


Did this page help you?