Ansible Pilot

Backup Config on Dell EMC Networking Operating System DNOS 6 - Ansible Network dellemc.os6

How to automate network device configuration backup for Dell EMC OS6 network appliances connecting via SSH protocol using the username and password credentials with Enable Mode (Privilege Escalation) and save it to a file using Ansible Network dellemc.os6.

How to Backup Config on Dell EMC Networking Operating System DNOS 6 with Ansible?

Maintaining a backup copy of your network appliance configuration is a good practice for all IT professionals. You could automate this process for Dell EMC network appliances using Ansible. I’m going to show you a live demo with some simple Ansible code. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

Ansible Backup Config on DNOS 6

Let’s talk about the Ansible module os6_config. The full name is dellemc.os6.os6_config, which means that is part of the collection dellemc.os6 specialized in the module to interact with Ansible Network Collection for Dell EMC OS6. This collection requires ansible-core version 2.10+. It manages Dell EMC OS6 configuration sections.

Parameters

Let me summarize the parameter of os6_config module for the backup use-case. The backup boolean enables the backup mode of the configuration. Once enabled you could specify some backup_options. I suggest you specify the dir_path, the directory where to save backups, and the filename if you have a specific one. Otherwise, Ansible is going to create a file with the current timestamp.

Demo

How to Backup Config on Dell Networking Operating System 6 with Ansible Playbook. I’m going to show how to back up the current configuration of a Dell Networking Operating System 6 connecting via SSH protocol using username and password credentials with Enable Mode (Privilege Escalation) and save it to a file with the device name and timestamp.

code

[dellos6]
192.168.88.3
[dellos6:vars]
ansible_user=luca
ansible_password=mysecretpassword123
ansible_become=yes
ansible_become_method=enable
ansible_connection=ansible.netcommon.network_cli
ansible_network_os=dellemc.os6.os6
ansible_command_timeout=120
---
- name: Backup DNOS6
  hosts: dellos6
  gather_facts: false
  vars:
    backup_dir: "/home/luca/network/backup"
  tasks:
    - name: Backup
      dellemc.os6.os6_config:
        backup: true
        backup_options:
          dir_path: "{{ backup_dir }}"
---
collections:
  - name: dellemc.os6

requirements setup

$ ansible-galaxy install -r requirements.yml 
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading https://galaxy.ansible.com/download/dellemc-os6-1.0.7.tar.gz to /home/luca/.ansible/tmp/ansible-local-46189694_j598/tmp2rjavc0i/dellemc-os6-1.0.7-1grhtwx1
Installing 'dellemc.os6:1.0.7' to '/home/luca/.ansible/collections/ansible_collections/dellemc/os6'
Downloading https://galaxy.ansible.com/download/ansible-netcommon-3.0.0.tar.gz to /home/luca/.ansible/tmp/ansible-local-46189694_j598/tmp2rjavc0i/ansible-netcommon-3.0.0-ctz29dou
dellemc.os6:1.0.7 was installed successfully
Installing 'ansible.netcommon:3.0.0' to '/home/luca/.ansible/collections/ansible_collections/ansible/netcommon'
Downloading https://galaxy.ansible.com/download/ansible-utils-2.6.1.tar.gz to /home/luca/.ansible/tmp/ansible-local-46189694_j598/tmp2rjavc0i/ansible-utils-2.6.1-ytnvukj8
ansible.netcommon:3.0.0 was installed successfully
Installing 'ansible.utils:2.6.1' to '/home/luca/.ansible/collections/ansible_collections/ansible/utils'
ansible.utils:2.6.1 was installed successfully
$ ansible-galaxy collection list
# /home/luca/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
ansible.netcommon 3.0.0  
ansible.utils     2.6.1  
dellemc.os6       1.0.7  

first run

Firstly you need to save the SSH fingerprint of the network device on your system. You could execute an SSH connection, reply yes when asked to save the fingerprint, and terminate (CTRL+C).

$ ssh [email protected]
The authenticity of host '192.168.88.3 (192.168.88.3)' can't be established.
RSA key fingerprint is SHA256:*********************************************.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.88.3' (RSA) to the list of known hosts.
[email protected]'s password:

execution

$ ansible-playbook -i inventory backup_dellos6.yml
PLAY [Backup DNOS6] *******************************************************************************
TASK [Backup] *************************************************************************************
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
changed: [192.168.88.3]
PLAY RECAP ****************************************************************************************
192.168.88.3               : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

before execution

$ pwd
/home/luca/network
[email protected]:~/network$ ls
backup_dellos6.yml  inventory  requirements.yml
$ ansible --version
ansible [core 2.12.4]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/luca/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/luca/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
  jinja version = 2.10.1
  libyaml = True

after execution

$ ls -al backup
total 16
drwxrwxr-x 2 luca luca 4096 May  5 09:46 .
drwxr-xr-x 3 luca luca 4096 May  5 09:45 ..
-rw-rw-r-- 1 luca luca  610 May  5 09:45 [email protected]:45:54
-rw-rw-r-- 1 luca luca  610 May  5 09:46 [email protected]:46:27
[email protected]:~/network$ file backup/*
backup/[email protected]:45:54: ASCII text
backup/[email protected]:46:27: ASCII text
[email protected]:~/network$

code with ❤️ in GitHub

Recap

Now you know how to Backup Config on Dell EMC Networking Operating System DNOS 6 with Ansible. Subscribe to the YouTube channel, Medium, Website and Twitter to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my

My book Ansible By Examples: 100+ Automation Examples For Linux and Windows System Administrator and DevOps

Want to keep this project going? Please donate

Trustpilot
Follow me

Subscribe not to miss any new releases

May 5, 2022

FREE Top 10 Best Practices

Top 10 Best Practices of Ansible Automation: save time, reduce errors and stress