HomeGuidesAPI Reference
GuidesAPI ReferenceGitHubAirheads Developer CommunityLog In
Guides

Getting Started with Ansible and HPE Aruba Networking Fabric Composer

Ansible is an open-source automation framework that was created by Ansible and now maintained by RedHat. 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 HPE Aruba Networking Fabric Composer, among other HPE Aruba Networking products.

If you aren't already familiar with Ansible, please read through the pages linked here:

Getting Started with Ansible

Installing Ansible

Ansible Inventories

Ansible Automation Platform

📘

HPEANFC Ansible Collection on Galaxy

Find the HPEANFC Collection on GitHub and for the most recent HPE Aruba Networking Ansible content visit Ansible Galaxy .

Installing the Collection

Our HPE Aruba Networking Fabric Composer Ansible modules are packaged in the HPE Aruba Networking Fabric Composer collection.

Requirements

  • Python 3.5+
  • Ansible 2.15.0 or later

The HPE Aruba Networking Fabric Composer Collection was created for users to manage HPEANFC using REST API. To install the collection, issue the "ansible-galaxy" command: ansible-galaxy collection install arubanetworks.afc

If you plan on using the HPE Aruba Networking Fabric Composer Collection with the 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 Fabric Composer Collection your collections/requirements.yml file should include the following:

collections:
- arubanetworks.afc

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 Python required packages which are defined in the requirements.txt file within the collection. You can do so with the following command:
pip install -r requirements.txt

Setting up the Ansible Inventory for HPE ANW Fabric Composer

The HPE Aruba Networking Fabric Composer Ansible modules use REST API. For information on REST API and instructions for obtaining access to the REST API, see the Developer Hub pages in the HPE ANW Fabric Composer REST API section, beginning with Getting Started with the HPE ANW Fabric Composer API

Inventory Variables

The HPE ANFC Collection supports authentication either by using the administrative username and password or by directly providing a valid authentication token, these variables can be defined in your inventory or supplied to the task itself. Ansible has built in methods for encrypting sensitive information that is recommended for these values. The variables that should be defined in your inventory for your HPE Aruba Networking Fabric Composer account are:

  • afc_ip: IP address of Fabric Composer in A.B.C.D format.
  • afc_username: Administrative username for AFC in plaintext format.
  • afc_password: Administrative Password for AFC in plaintext format.
  • auth_token: Authentication token generated using API endpoint /auth/token - for detailed instructions see Getting Started with the HPE ANW Fabric Composer API Authentication. Required if afc_username and afc_password are not provided.

Sample Inventory

YAML

all:
  hosts:
    hpeanfc:
      afc_ip: 10.10.10.10
      afc_username: 'afc_admin'
      afc_password: 'afc_password'
all:
  hosts:
    hpeanfc:
      afc_ip: 10.10.10.10
      auth_token: '581db5d67e6aefc22e29a863b52a'

Sample Playbook

---
- name: Playbook to Create Fabric
  hosts: all
  collections:
    - arubanetworks.afc
  gather_facts: false
  tasks:
    - name: Day0 | create_fabric | Create Fabric using username and password
      arubanetworks.afc.afc_fabric:
        afc_ip: "{{ afc_ip }}"
        afc_username: "{{ afc_username }}"
        afc_password: "{{ afc_password }}"
        operation: 'create'
        data:
          name: "SJQ-DCN-FABRIC"
          timezone: "America/Los_Angeles"

---
- name: Playbook to assign Fabric
  hosts: all
  collections:
    - arubanetworks.afc
  gather_facts: false
  tasks:
    - name: Create Session
      arubanetworks.afc.afc_session:
        afc_ip: "{{ afc_ip }}"
        afc_username: "{{ afc_username }}"
        afc_password: "{{ afc_password }}"
      register: reg_afc_instance
    
    - name: Capture the auth_token
      ansible.builtin.set_fact:
        auth_token: "{{ reg_afc_instance['auth_token'] }}"
  
    - name: Day0 | create_fabric | Create Fabric with token
      arubanetworks.afc.afc_fabric:
        afc_ip: "{{ afc_ip }}"
        auth_token: "{{auth_token}}"
        operation: 'create'
        data:
          name: "SJQ-DCN-FABRIC"
          timezone: "America/Los_Angeles"

What’s Next