Hi,
If you're interested in automating ArubaOS with ansible, I wrote a set of modules to automate ArubaOS 8 that can help with that.
You can find it on github at:
https://github.com/sachaboudjema/ansible-modules-arubaos
List of modules
- arubaos_controller_config: Backward compatibility with playbooks based on the module found at aruba/aruba-ansible-modules
- arubaos_get: Executes GET operations on API objects
- arubaos_set: Add, modify or delete configuration
- arubaos_facts: Populates ansible_facts with sys_info details about the system to which the query is being sent
- arubaos_config: Queries full or partial configuration of a particular configuration node.
- arubaos_writememory: Executes a show command on the controller and returns structured data when supported
- arubaos_showcommand: Commits the pending configuration (if any) on the specified node
Noteworthy features
General
- Arguments host, username and password support fallback to env variables ANSIBLE_ARUBAOS_HOST, ANSIBLE_ARUBAOS_USERNAME, ANSIBLE_ARUBAOS_PASSWORD to avoid having to repeat them on each module call.
arubaos_controller_config
- Provides backwards compatibility with playbooks based on the module found at aruba/aruba-ansible-modules.
arubaos_get
- Implements all get modifiers (i.e. filters) supported by the API
arubaos_set
- Fully idempotent
- Support for check_mode and diff
- Support for normal and mulipart set operation
Example playbook
Here is an example playbook displaying some of the features provided by these modules:
---
- name: "Example playbook for ArubaOS modules"
hosts: 127.0.0.1
connection: local
gather_facts: no
environment:
ANSIBLE_ARUBAOS_HOST: "{{ mm_ip }}"
ANSIBLE_ARUBAOS_USERNAME: "{{ mm_username }}"
ANSIBLE_ARUBAOS_PASSWORD: "{{ mm_password }}"
vars:
config_path: "/md/branch1/floor1"
tasks:
- name: Gather facts
arubaos_facts:
tags: facts
- name: Show command
arubaos_showcommand:
command: show switches
tags: showcommand
- name: Write memory
arubaos_writememory:
config_path: "{{ config_path }}"
tags: writememory
- name: Get Config
arubaos_config:
config_path: "{{ config_path }}"
tags: config
- name: Get Config with type filter
arubaos_config:
config_path: "{{ config_path }}"
type: local
tags: config
- name: Get objects
arubaos_get:
config_path: "{{ config_path }}"
object: ap_group
tags: get
- name: Get with sort
arubaos_get:
config_path: "{{ config_path }}"
object: ap_group
sort: '-id'
tags: get
- name: Get with pagination
arubaos_get:
config_path: "{{ config_path }}"
object: ap_group
limit: 2
offset: 2
total: 10
tags: get
- name: Get with object filter
arubaos_get:
config_path: "{{ config_path }}"
object: ap_group
object_filters:
- oper: $eq
values: ['ap_group.ap_sys_prof', 'ap_group.am_filter_prof']
tags: get
- name: Get with data filter
arubaos_get:
config_path: "{{ config_path }}"
object: ap_group
data_filters:
- param_name: 'ap_group.profile-name'
oper: $in
values: ['default']
tags: get
- name: Get with data type filter
arubaos_get:
config_path: "{{ config_path }}"
object: ap_group
data_types: ['non-default']
tags: get
- name: Set single object single instance
arubaos_set:
config_path: "{{ config_path }}"
data:
ap_group:
profile-name: "grp-test-ansible-sOsI"
tags: set
- name: Set single object multiple instance
arubaos_set:
config_path: "{{ config_path }}"
data:
ap_group:
- profile-name: "grp-test-ansible-1"
- profile-name: "grp-test-ansible-2"
tags: set
- name: Set & commit single object multiple instance
arubaos_set:
config_path: "{{ config_path }}"
data:
ap_group:
- profile-name: "grp-test-ansible-1"
- profile-name: "grp-test-ansible-2"
commit: true
tags: set
- name: Set multiple object multiple instance
arubaos_set:
config_path: "{{ config_path }}"
data:
server_group_prof:
- sg_name: "sg_grp-test_ansible-1"
- sg_name: "sg_grp-test_ansible-2"
ap_group:
- profile-name: "grp-test-ansible-1"
- profile-name: "grp-test-ansible-2"
tags: set
- name: Set multi-part & commit (continue if error)
arubaos_set:
config_path: "{{ config_path }}"
multipart_data:
- ap_group:
profile-name: "grp-test-ansible-3"
- server_group_prof:
- sg_name: "sg_grp-test_ansible-1"
- sg_name: "sg_grp-test_ansible-2"
ap_group:
- profile-name: "grp-test-ansible-1"
- profile-name: "grp-test-ansible-2"
commit_force: true
tags: set
Feedback is of high value to improve code, so don't hesitate.
Enjoy.