AOS-CX

The AOS-CX Developer Hub

Welcome to the AOS-CX developer hub. You'll find comprehensive guides and documentation to help you start working with AOS-CX as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Using the AOS-CX Ansible Collection

Installing and using the AOS-CX collection

There are two approaches to using the AOS-CX modules: role and collection. A guide for the latter is detailed here. For the alternative method, see the instructions for using the AOS-CX Ansible Role.

In order to use the AOS-CX Ansible collection to configure AOS-CX hosts, REST API access must be enabled on each host. Please follow the steps outlined here: Enabling the AOS-CX API.

What is an Ansible collection?

In Ansible, a collection is used to bundle up and distribute Ansible content, including items such as playbooks, roles, modules, and plugins.

Installing the Collection

Our AOS-CX Ansible modules are packaged in the AOS-CX collection. They are also packaged in the AOS-CX role. For instructions on installing and using the modules with the alternative role approach, please see this page.

To install the collection, issue the "ansible-galaxy" command:
ansible-galaxy collection install arubanetworks.aoscx

If you plan on using the AOS-CX collection in an Ansible Tower environment, make sure to provide the full path to a location in which Ansible Tower looks for installed collections. Ansible Tower looks in multiple places for installed collections. For example, one such path is /usr/share/ansible/collections:
ansible-galaxy collection install arubanetworks.aoscx -p /usr/share/ansible/collections

To upgrade your existing installation of the collection to the latest updated collection, simply re-run the appropriate "ansible-galaxy" command listed above. Ansible will check to see if the existing collection is out of date and if so, install the latest version.

AOS-CX Module Support and Compatibility

All of Aruba's Ansible modules can be run with both Ansible Engine and the Ansible GUIs (Ansible Tower and AWX). The sole requirement is Ansible version 2.9.0 or later.

Module
8400
8325
8320
6400
6300

aoscx_acl

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_acl_interface

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_acl_vlan

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_backup_config

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_banner

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_boot_firmware

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_checkpoint

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_command

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_config

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_dns

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_facts

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_l2_interface

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_l3_interface

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_static_route

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_upload_config

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_upload_firmware

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_vlan

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_vlan_interface

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

aoscx_vrf

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

:white-check-mark+:

Platform
Firmware

8400

XL.10.03.001 and later

8325

GL.10.03.001 and later

8320

TL.10.03.001 and later

6400

FL.10.04.001 and later

6300

FL.10.04.001 and later

SSH/CLI Modules

All of our modules in the AOS-CX collection are written to use REST API for connection and configuration with a few exceptions, save for a couple of exceptions. The modules aoscx_config and aoscx_command use SSH to connect to the AOS-CX switch to execute CLI commands. These modules can be used in addition to or instead of the REST API modules provided in the role.

  • To use the SSH/CLI modules aoscx_config and aoscx_command, SSH access must be enabled on your AOS-CX device. It is enabled by default.
    • If necessary, re-enable SSH access on the device with the following command:
      switch(config)# ssh server vrf mgmt
  • The control machine's known_hosts file must contain the target device's public key.
    • Alternatively, host key checking by the control machine may be disabled, although this is not recommended. To disable host key checking, modify the ansible.cfg file (located by default at /etc/ansible/ansible.cfg) to include:
      host_key_checking = false

Limitations and Notes

  • The default command timeout is 30 seconds. If a command takes more than 30
    seconds to execute, the task will time out.
    • If you regularly encounter the command timeout triggered, timeout value is 30 secs error, consider setting the environment variable
      ANSIBLE_PERSISTENT_COMMAND_TIMEOUT to a greater value. See Ansible documentation here.

Inventory Setup

In addition to installing the AOS-CX collection, you must also add any AOS-CX hosts to the Ansible inventory. For each AOS-CX switch, the following inventory variables must be defined:

  • ansible_host: IP address of the switch in A.B.C.D format; for IPv6 hosts use a string and enclose the IP address in square brackets (e.g. '[2001::1]')
  • ansible_user: Username for the switch in plaintext
  • ansible_password: Password for the switch in plaintext
  • ansible_network_os: Must always be set to arubanetworks.aoscx.aoscx
  • ansible_connection: Set to httpapi to use REST API modules, and to network_cli to use SSH/CLI modules
    • See below for info on using both REST API modules and SSH/CLI modules on a host
  • ansible_httpapi_use_ssl: (Only required for REST API modules) Must always be True as AOS-CX uses port 443 for REST
  • ansible_httpapi_validate_certs: May be set to either True or False depending on whether Ansible should attempt to validate SSL certificates on the device
  • ansible_acx_no_proxy: May be set to either True or False depending on whether Ansible should bypass environment proxies when connecting to the switch

Example inventories for REST API (each with one host)

INI

aoscx_1 ansible_host=10.0.0.1 ansible_user=admin ansible_password=password ansible_connection=httpapi ansible_network_os=arubanetworks.aoscx.aoscx ansible_httpapi_validate_certs=False ansible_httpapi_use_ssl=True ansible_acx_no_proxy=True

YAML

all:
  hosts:
    aoscx_1:
      ansible_host: 10.0.0.1
      ansible_user: admin
      ansible_password: password
      ansible_connection: httpapi  # REST API connection method
      ansible_network_os: arubanetworks.aoscx.aoscx
      ansible_httpapi_validate_certs: False
      ansible_httpapi_use_ssl: True
      ansible_acx_no_proxy: True

Example inventories for SSH/CLI (each with one host)

INI

aoscx_1 ansible_host=10.0.0.1 ansible_user=admin ansible_password=password ansible_connection=network_cli ansible_network_os=arubanetworks.aoscx.aoscx

YAML

all:
  hosts:
    aoscx_1:
      ansible_host: 10.0.0.1
      ansible_user: admin
      ansible_password: password
      ansible_connection: network_cli  # SSH connection method
      ansible_network_os: arubanetworks.aoscx.aoscx

Example Playbook

Note the inclusion of the collection with collections: and - ...:

---
-  hosts: all
   collections:
     - arubanetworks.aoscx
   tasks:
     - name: Create L3 Interface 1/1/3
       aoscx_l3_interface:
        interface: 1/1/3
        description: Uplink_Interface
        ipv4: ['10.20.1.3/24']
        ipv6: ['2001:db8::1234/64']

Using Both REST API and SSH/CLI Modules on a Host

To use both REST API and SSH/CLI modules on the same host, you must create separate plays such that each play uses either only REST API modules or only SSH/CLI modules. A play cannot mix and match REST API and SSH/CLI module calls.

In each play, ansible_connection must possess the appropriate value according to the modules used. If the play uses REST API modules, that value should be httpapi. If the play uses SSH/CLI modules, that value should be network_cli.

A recommended approach to successfully using both types of modules for a host is as follows:

  1. Set the host variables such that Ansible will connect to the host using REST API, like seen above.
  2. In the playbook, in each play wherein the SSH/CLI modules are used, set the ansible_connection to network_cli.

The inventory should look something like this:

all:
  hosts:
    aoscx_1:
      ansible_host: 10.0.0.1
      ansible_user: admin
      ansible_password: password
      ansible_network_os: arubanetworks.aoscx.aoscx
      ansible_connection: httpapi  # REST API connection method
      ansible_httpapi_validate_certs: False
      ansible_httpapi_use_ssl: True
      ansible_acx_no_proxy: True

and the playbook like this (note how the second play, which uses the SSH/CLI module aoscx_command, sets the ansible_connection value accordingly):

- hosts: all
  collections:
    - arubanetworks.aoscx
  tasks:
    - name: Adding or Updating Banner
      aoscx_banner:
        banner_type: banner
        banner: "Hi!"

- hosts: all
  collections:
    - arubanetworks.aoscx
  vars:
    ansible_connection: network_cli
  tasks:
    - name: Execute show run on the switch
      aoscx_command:
        commands: ['show run']

Updated 5 months ago



Using the AOS-CX Ansible Collection


Installing and using the AOS-CX collection

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.