This demo shows how you can easily backup your entire Alcatel-Lucent Enterprise Omniswitch environment using Ansible. You can store the backup files locally or even better, push them to a remote GIT repository. The result is a CMDB (configuration management database) in which the different backup versions are stored and where you can easily compare them to track changes.
For AOS6 devices we use Gilbert Moisio’s “ale_aos” Ansible collection to save the CLI output captured from the “show configuration snapshot” command through SSH. For AOS8 devices we can utilise the REST API to send the necessary GET requests via the Ansible built-in “uri” module.
What is Ansible: Ansible is an open-source orchestration tool for automating application deployment and configuration management, enabling infrastructure as a code.
You can find all the demo files in the ansible-aos-demo GitHub repository. Clone the remote repository to a local folder to get started:
git clone https://github.com/jefvantongerloo/ansible-aos-demo.git
Installation: Python modules, Ansible collections
Before we get started we need to install some Python modules and the desired Ansible collections. For example, the ale_aos Ansible collection makes underlying use of the Python package Netmiko. We install from two files in which we track dependencies: requirements.txt and requirements.yml.
--- collections: - name: gmoisio.ale - name: lvrfrc87.git_acp version: "1.1.3" - name: community.general
- Install Python requirements
pip3 install -r requirements.txt
- Install Ansible-galaxy collecties
ansible-galaxy collection install -r requirements.yml
Test the Ansible and the Ansible-galaxy collections installation by running the following terminal commands:
ansible --version ansible-galaxy collection list
jefvantongerloo:$ ansible --version ansible 2.10.16 config file = None configured module search path = ['/home/p064033/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/p064033/.local/lib/python3.8/site-packages/ansible executable location = /home/p064033/.local/bin/ansible python
Host and variable configuration
Add all desired hosts to the inventory.yml file and specify the correct device_os of the device, respectively aos6 and aos8. Through this parameter, we will later determine whether to use SSH (slow) or REST API (fast) to interact with the device.
--- all: hosts: NET-SWI-001: ansible_host: 10.10.0.1 device_vendor: alcatel device_os: aos8
In our Ansible playbook we use the variable “ale_username” and “ale_password” to login to the switches. By adding this as a group variable in the file “group_vars / all / all.yml” they are available for the group “all”, i.e. all hosts.
--- ale_username: amdin ale_password: switch
The Ansible backup playbook can store the backup configuration locally or on a remote git repository. By altering the “backup_git” variable with “true” or “false” you can activate this functionality. If you are pushing backups to git, also complete the set of git parameters to allow Ansible accessing your GIT repository.
backup_local: true backup_git: false
git_token: "" git_username: "" git_url: "" git_branch: "master"
Execute Ansible playbook backup.yml
Final step is to run the backup-all.yml ansible playbook:
All playbook tasks from the backup-all.yml file are now executed sequentially. Taking into account our “device_os” parameter, only relevant tasks for the host are performed. If everything goes well, the counter of failed tasks will remain at zero.
If the local backup option is activated, a folder structure has been created in the “backups” folder containing the configuration files.