This Article will contain Ansible playbook setup example against Dell Switches.

Ansible notes will be posted here and continuesly updated on the fly when required.

Ansible environment as always devided for 2 servers: PRODuction and DEVelopment.
Tested scrypts will be moved from DEV into PROD server once fully tested and ready.

Aruba OSCX playbooks required additional roles installed

Next CLI command will be applied to both servers:
ansible-galaxy install arubanetworks.aoscx_role
ansible-galaxy collection install ansible.netcommon
 
Also, changes to the ansible.conf:
host_key_auto_add = True

 

Host file content:

Ansible configuration files location: /etc/ansible

[AOSCX]
AOSCX01 ansible_host=10.x.x.x1
AOSCX01 ansible_host=10.x.x.x2


[AOSCX:vars]

ansible_user=admin
ansible_ssh_pass=****

Manual execution (for test):

ansible-playbook aoscx.yml

 

Output files location:

ls home/administrator/network-programmability/
 

Scheduling done over crontub:

# Execute against Aruba OS CX switches
5 6 * * * if ! out=`ansible-playbook /etc/ansible/aoscx.yml`; then echo $out; fi

 

Playbook:

---
## Playbook to get system time and append it to backup files for Aruba OS CX
## Made by DM
## Last change 09/06/2021

- hosts: localhost
  tasks:
   - name: Get ansible date/time facts
     setup:
       filter: "ansible_date_time"
       gather_subset: "!all"

   - name: Store DTG as fact
     set_fact:
       DTG: "{{ ansible_date_time.date }}"

   - name: Create Directory {{hostvars.localhost.DTG}}
     file:
      path: ~/network-programmability/backups/AOSCX/{{hostvars.localhost.DTG}}
      state: directory
  run_once: true

- hosts: AOSCX
  roles: 
    - role: arubanetworks.aoscx_role
  vars:
    ansible_connection: network_cli
  tasks:
    - name: Execute show run on the switch
      aoscx_command:
        commands: ['show run']
      register: config
    - name: Save output to ~/network-programmability/backups/AOSCX
      copy:
        content: "{{config.stdout[0]}}"
        dest: "/home/administrator/network-programmability/backups/AOSCX/{{hostvars.localhost.DTG}}/{{inventory_hostname}}-{{hostvars.localhost.DTG}}-config.txt"