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" 


Google AdSence

AUST IT - Computer help out of hours, when you need it most.

Find out why we do it for less.

About

AUST IT will help you resolve any technical support issues you are facing onsite or remotely via remote desktop 24/7. More...

Contacts

Reservoir, Melbourne,
3073, VIC, Australia

Phone: 0422 348 882

This email address is being protected from spambots. You need JavaScript enabled to view it.

Sydney: 0481 837 077

Connect

Join us in social networks to be in touch.

Newsletter

Complete the form below, and we'll send you our emails with all the latest AUST IT news.