Perform local backup on target Nodegrid with Ansible

Perform local backup on target Nodegrid with Ansible

Ansible can be used to save current configuration of Nodegrid device and saved as a backup file.

In local backup, the saved configuration will be saved locally in the Nodegrid.

This is the template file one needs for this task: localbackup.j2
Here template file is in templates folder. So, the path is /etc/ansible/templates/localbackup.j2

  1. cd /system/toolkit
  2. save_settings
  3. set destination=local_system
  4. set filename={{ ng_backup }}
  5. save
  6. finish
  7. commit

Next task is to create a playbook to run this task: localbackup.yml
This yml file is at /etc/ansible/localbackup.yml 

  1. ---
  2.  - name: Take a backup of remote nodegrid
  3.    hosts: Nodegrid
  4.    become: true
  5.    gather_facts: yes
  6.    vars:
  7.      ng_backup: newbackup
  8.    tasks:
  9.    - name: Copy template to remote nodegrid
  10.      template:
  11.        src: templates/localbackup.j2
  12.        dest: /tmp/localbackup.cli

  13.    - name: Apply the backup
  14.      command: cli -f /tmp/localbackup.cli

  15.    - name: ACK
  16.      debug:
  17.        msg: " Backup is created "
Now, run the playbook with command: ansible-playbook localbackup.yml

One will see that backup will be saved in /backup folder with filename given in the playbook.