Getting Started with Ansible
Installation and setup
Introduction
Ansible is an open-source automation framework that was created by Ansible and now maintained by Red Hat. Ansible is an orchestration tool that automates provisioning, configuration management, and application deployment.
In 2019, HPE Aruba Networking became an official Ansible partner, and currently supports Ansible for Central, among other HPE Aruba Networking products.
If you aren't already familiar with Ansible, please read through the pages linked here:
Installing the Collection
Our HPE Aruba Networking Central Ansible modules are packaged in the HPE Aruba Networking Central collection.
- Python 2.7 or 3.5+
- Ansible 2.9.0 or later
- Minimum supported Aruba Central firmware version 2.5.2
The HPE Aruba Networking Central collection was created solely for the sake of bundling up the Central Ansible modules for easy distribution and consumption. To install the collection, issue the "ansible-galaxy" command: ansible-galaxy collection install arubanetworks.aruba_central
If you plan on using the Aruba HPE Aruba Networking Central collection with Ansible Automation Platform you'll need a directory labeled collections/ with a requirements.yml file. This file is what your automation controller will use to install any Ansible collection dependencies at run time. To execute playbooks using the HPE Aruba Networking Central Ansible Collection your collections/requirements.yml file should include the following:
collections:
- arubanetworks.aruba_central
To install the latest updated collection, simply re-run any of the previous commands. Ansible Galaxy will check to see if the existing collection is out of date and install the latest version.
Additionally, you'll need to install the requests library. You can do so with the following command:
pip install -r requirements.txt
Setting up the Ansible Inventory for HPE Aruba Networking Central
- The HPE Aruba Networking Central Ansible modules use Central's REST API. For information on REST API and instructions for obtaining access to the REST API, see the Developer Hub pages in the HPE Aruba Networking Central REST API section, beginning with Getting Started with REST API
- An API token must be created for a user on Central and a valid, non-expired access_token must be present
- Ensure that the access token was created with "Network Operations" selected in the Application drop-down list.
An access token is valid for a period of 7200 seconds or two hours. After two hours, it will expire and a new token needs to be created. The token expiry time is currently not configurable.
Your Ansible inventory will likely be rather modest as it will only contain the Central instance(s) as opposed to all the target devices, which will in turn be managed by Central.
Inventory Variables
The variables that should be defined in your inventory for your Aruba Central account are:
ansible_host
: Base URL path for API-gateway on HPE Aruba Networking Central in FQDN formatansible_connection
: Must always be set tohttpapi
ansible_network_os
: Must always be set toaruba_central
ansible_httpapi_use_ssl
: Must always be set toTrue
ansible_httpapi_session_key
: HPE Aruba Networking Central's API access token
Sample Inventories
INI
arubacentral ansible_host=internal-apigw.central.arubanetworks.com ansible_connection=httpapi ansible_network_os=aruba_central ansible_httpapi_use_ssl=True ansible_httpapi_central_access_token=CnjDaXXxvnjrvJRwxxxxXXxxXXXXxxxx
YAML
all:
hosts:
central:
ansible_host: internal-apigw.central.arubanetworks.com
ansible_connection: httpapi
ansible_network_os: aruba_central
ansible_httpapi_use_ssl: True
ansible_httpapi_central_access_token: CnjDaXXxvnjrvJRwxxxxXXxxXXXXxxxx
Updated about 2 months ago