-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Network Backups to show using validated content to back up netw…
…ork devices (#214) Co-authored-by: Todd Ruch <[email protected]>
- Loading branch information
Showing
4 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
- name: Create network reports server | ||
hosts: reports | ||
become: true | ||
|
||
tasks: | ||
- name: Build report server | ||
ansible.builtin.include_role: | ||
name: "{{ item }}" | ||
loop: | ||
- demo.patching.report_server | ||
|
||
- name: Create a backup directory if it does not exist | ||
run_once: true | ||
ansible.builtin.file: | ||
path: "/var/www/html/backups" | ||
state: directory | ||
owner: ec2-user | ||
group: ec2-user | ||
mode: '0755' | ||
|
||
- name: Play to Backup Cisco Always-On Network Devices | ||
hosts: routers | ||
gather_facts: false | ||
vars: | ||
report_server: reports | ||
backup_dir: "/tmp/network_backups" | ||
|
||
tasks: | ||
- name: Network Backup and Resource Manager | ||
ansible.builtin.include_role: | ||
name: network.backup.run | ||
vars: # noqa var-naming[no-role-prefix] | ||
operation: backup | ||
type: full | ||
data_store: | ||
local: "{{ backup_dir }}" | ||
|
||
# This task removes the Current configuration... from the top of IOS routers show run | ||
- name: Remove non config lines - regexp | ||
delegate_to: localhost | ||
ansible.builtin.lineinfile: | ||
path: "{{ backup_dir }}/{{ inventory_hostname }}.txt" | ||
line: "Building configuration..." | ||
state: absent | ||
|
||
- name: Copy backup file | ||
delegate_to: "{{ report_server }}" | ||
ansible.builtin.copy: | ||
src: "{{ backup_dir }}/{{ inventory_hostname }}.txt" | ||
dest: "/var/www/html/backups/{{ inventory_hostname }}.cfg" | ||
backup: true | ||
owner: ec2-user | ||
group: ec2-user | ||
mode: '0644' | ||
|
||
- name: Review backup on report server | ||
delegate_to: "{{ report_server }}" | ||
run_once: true | ||
ansible.builtin.debug: | ||
msg: "To review backed up configurations, go to http://{{ ansible_host }}/backups/" | ||
|
||
... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[ios] | ||
sandbox-iosxe-latest-1.cisco.com | ||
|
||
[ios:vars] | ||
ansible_network_os=cisco.ios.ios | ||
ansible_password=C1sco12345 | ||
ansible_ssh_password=C1sco12345 | ||
ansible_port=22 | ||
ansible_user=admin | ||
|
||
[iosxr] | ||
sandbox-iosxr-1.cisco.com | ||
|
||
[iosxr:vars] | ||
ansible_network_os=cisco.iosxr.iosxr | ||
ansible_password=C1sco12345 | ||
ansible_ssh_pass=C1sco12345 | ||
ansible_port=22 | ||
ansible_user=admin | ||
|
||
[nxos] | ||
sbx-nxos-mgmt.cisco.com | ||
sandbox-nxos-1.cisco.com | ||
|
||
[nxos:vars] | ||
ansible_network_os=cisco.nxos.nxos | ||
ansible_password=Admin_1234! | ||
ansible_ssh_pass=Admin_1234! | ||
ansible_port=22 | ||
ansible_user=admin | ||
|
||
[routers] | ||
sbx-nxos-mgmt.cisco.com | ||
sandbox-nxos-1.cisco.com | ||
sandbox-iosxr-1.cisco.com | ||
sandbox-iosxe-latest-1.cisco.com | ||
|
||
[routers:vars] | ||
ansible_connection=ansible.netcommon.network_cli | ||
|
||
[webservers] | ||
reports ansible_host=ec2-18-118-189-162.us-east-2.compute.amazonaws.com ansible_user=ec2-user |
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