Created
October 2, 2016 01:26
-
-
Save privateip/d0fd3c6459c5e1a4c1f9dceeb018b109 to your computer and use it in GitHub Desktop.
playbook to backup network device running configuration to local file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: ios | |
connection: local | |
vars: | |
backup_root: /tmp/backups | |
cli: | |
host: "{{ inventory_hostname }}" | |
username: cisco | |
password: cisco | |
transport: cli | |
tasks: | |
- name: run show running-config on remote devices | |
ios_command: | |
commands: show running | |
provider: "{{ cli }}" | |
register: config | |
- name: ensure backup folder is created | |
file: | |
path: "{{ backup_root }}" | |
state: directory | |
run_once: yes | |
- name: ensure device rolder is created | |
file: | |
path: "{{ backup_root }}/{{ inventory_hostname }}" | |
state: directory | |
- name: get timestamp | |
command: date +%Y%m%d | |
register: timestamp | |
- copy: | |
content: "{{ config.stdout[0] }}" | |
dest: "{{ backup_root }}/{{ inventory_hostname }}/running-config_{{ timestamp.stdout }}" |
Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp". Failed command was: ( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-2756uxxwdzsa/ansible-
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match