Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
---
- 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