Skip to content

Instantly share code, notes, and snippets.

@NilashishC
Created November 19, 2019 11:15
Show Gist options
  • Save NilashishC/e2452aa7e15ab3623e68d6b9fe1d4a5f to your computer and use it in GitHub Desktop.
Save NilashishC/e2452aa7e15ab3623e68d6b9fe1d4a5f to your computer and use it in GitHub Desktop.
---
- hosts: aws_csr
gather_facts: no
vars:
backup_directory: ~/Desktop/csr
tasks:
- name: Create Backup Directory
file:
path: "{{ backup_directory }}"
state: directory
- name: Take backup of running config
ios_config:
backup: yes
backup_options:
dir_path: "{{ backup_directory }}"
tags:
- initial_backup
- name: Update interface description
ios_config:
lines:
- description 'TEST_INTERFACE_1'
parents: interface GigabitEthernet1
register: result
tags:
- changes
- name: Take backup if the above task resulted in changes
ios_config:
backup: yes
backup_options:
dir_path: "{{ backup_directory }}"
when: result.changed == True
tags:
- changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment