Skip to content

Instantly share code, notes, and snippets.

@robphoenix
Created February 9, 2017 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robphoenix/5ff6aed90686bf7458cf5c730a1dbd7b to your computer and use it in GitHub Desktop.
Save robphoenix/5ff6aed90686bf7458cf5c730a1dbd7b to your computer and use it in GitHub Desktop.
---
- name: Create tmp Directory
hosts: 127.0.0.1
connection: local
tasks:
- name: Create tmp Directory
file: path=../../tmp state=directory
- name: Fetch running-config
gather_facts: no
hosts: stage_2_dev_1
tasks:
- name: Execute write mem
ios_command:
provider: "{{ provider }}"
commands:
- wr mem
register: output
- debug:
var: output
- name: Execute 'show run' command
ios_command:
provider: "{{ provider }}"
commands:
- show run
register: output
- name: Write 'show run' to file
template:
src: output.txt.j2
dest: "../../tmp/{{ inventory_hostname }}-pre-running-config.txt"
- name: Move files
hosts: 127.0.0.1
connection: local
tasks:
- name: Delete directory
file: path=./backups/running_configs state=absent
- name: Move files to shared directory
command: mv ../../tmp ./backups/running_configs
- name: Remove tmp Directory
file: path=../../tmp state=absent
- name: Reload
gather_facts: no
hosts: stage_2_dev_1
tasks:
- name: Reload in 15 minutes
ntc_reboot:
platform: cisco_ios_ssh
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
host: "{{ ansible_host }}"
confirm: true
timer: 15
register: output
- debug:
var: output
- name: Change transport settings
ios_config:
provider: "{{ provider }}"
lines:
- transport input ssh
- transport output ssh
parents: line vty 0 15
register: output
- debug:
var: output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment