Creating Library Configuration Profiles
Source CodeYou 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_idandclient_secretfor New Central
Installation
- Install the collection from Ansible Galaxy:
ansible-galaxy collection install arubanetworks.hpeanw_central- Install the
pycentralv2 SDK, which the collection depends on:
pip3 install --pre pycentralThis 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-guestRun it with:
ansible-playbook -i inventory.yml central_profiles_demo.ymlModule Parameters (central_profiles)
central_profiles)| Parameter | Type | Required | Description |
|---|---|---|---|
path | str | Yes | Endpoint of the profile type, relative to /network-config/v1alpha1/ |
name | str | No | Profile identifier; recommended for idempotency on updates/deletes |
config_dict | dict | Yes | Profile configuration payload |
state | str | No | merged (default), replaced, or deleted |
Output
Each central_profiles task reports:
| Field | Description |
|---|---|
changed | true if the profile was created, modified, or deleted |
msg | Success message, or error details if the operation failed |
result | Response details; includes a diff of old_value/new_value when state: merged causes an update |
Troubleshooting
| Problem | Fix |
|---|---|
| Profile already exists errors | Set state: merged (default) instead of creating a new profile every run |
config_dict schema errors | Check the profile type's API reference for required fields at that path |
| VRF/gateway name collisions | VRF and gateway name values must be unique per profile type in the library |
Support
- Automation Team: [email protected]
- Collection Issues: GitHub Issues
Updated 4 months ago
Did this page help you?