This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Add other platforms #1
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6cdff39
Add other platforms
KB-perByte 8e1da22
fix end to end
KB-perByte 2cb6d4a
test lint
KB-perByte 0478f39
fix lint
KB-perByte 399bfab
add iosxr
KB-perByte 8d47f74
iosxr works
KB-perByte 74cb351
add nxos options
KB-perByte feb3b5a
fix nxos delete
KB-perByte 9d9f7fd
make checks reusable
KB-perByte 7f15111
fix appliance
KB-perByte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,5 @@ | ||
--- | ||
- name: Restore the config | ||
arista.eos.eos_config: | ||
replace: config | ||
src: "{{ network_backup_path }}" |
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,5 @@ | ||
--- | ||
- name: Restore operation for {{ network_os }} | ||
junipernetworks.junos.junos_config: | ||
update: replace | ||
src: "{{ network_backup_path }}" |
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,7 @@ | ||
--- | ||
- name: Set content specific facts | ||
ansible.builtin.set_fact: | ||
cli_restore_path: "{{ role_path }}/includes/cli_restore" | ||
|
||
- name: Invoke restore operation | ||
ansible.builtin.include_tasks: "{{ cli_restore_path }}/{{ network_os }}.yaml" |
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,17 @@ | ||
--- | ||
- name: Check restore file size | ||
ansible.builtin.stat: | ||
path: "{{ network_backup_path }}" | ||
register: restore_file_data | ||
|
||
- name: Inspect appliance size | ||
ansible.builtin.debug: | ||
var: appliance_dir_data | ||
|
||
- name: Inspect restore file size | ||
ansible.builtin.debug: | ||
var: restore_file_data | ||
|
||
- name: Assert file sizes | ||
assert: | ||
that: restore_file_data.stat.size < appliance_dir_data.free_bytes |
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
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,5 @@ | ||
--- | ||
- name: Delete the backup file post backup | ||
cisco.iosxr.iosxr_command: | ||
commands: | ||
- command: "delete {{ dest_dir }}{{ file_name }}.txt" |
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,5 @@ | ||
--- | ||
- name: Delete the backup file post backup | ||
cisco.nxos.nxos_command: | ||
commands: | ||
- command: "delete {{ appliance_dir }}{{ file_name }}.txt no-prompt" |
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,34 @@ | ||
--- | ||
- name: Set IOSXR directory - content specific facts | ||
ansible.builtin.set_fact: | ||
dest_dir: "/misc/scratch/" | ||
appliance_dir: "" | ||
|
||
- name: Parse free space information | ||
ansible.utils.cli_parse: | ||
command: "dir /all | include free" | ||
parser: | ||
name: ansible.netcommon.content_templates | ||
template_path: "{{ tmplt_path }}/{{ network_os }}.yaml" | ||
set_fact: appliance_dir_data | ||
|
||
- name: Check restore file size | ||
ansible.builtin.stat: | ||
path: "{{ network_backup_path }}" | ||
register: restore_file_data | ||
|
||
- name: Make appliance data unit relevant | ||
ansible.builtin.set_fact: | ||
applinace_data_dir_bytes: "{{ appliance_dir_data.free_bytes * 1024 }}" | ||
|
||
- name: Inspect appliance size | ||
ansible.builtin.debug: | ||
var: appliance_dir_data | ||
|
||
- name: Inspect restore file size | ||
ansible.builtin.debug: | ||
var: restore_file_data | ||
|
||
- name: Assert file sizes | ||
assert: | ||
that: restore_file_data.stat.size < applinace_data_dir_bytes |
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,16 @@ | ||
--- | ||
- name: Set NXOS directory - content specific facts | ||
ansible.builtin.set_fact: | ||
dest_dir: "bootflash:/" | ||
appliance_dir: "bootflash:///" | ||
|
||
- name: Parse free space information | ||
ansible.utils.cli_parse: | ||
command: "dir | include free" | ||
parser: | ||
name: ansible.netcommon.content_templates | ||
template_path: "{{ tmplt_path }}/{{ network_os }}.yaml" | ||
set_fact: appliance_dir_data | ||
|
||
- name: Include task to compare file size with free space | ||
ansible.builtin.include_tasks: "includes/common/healthcheck_common.yaml" |
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,10 @@ | ||
# fmt: off | ||
[ | ||
{ | ||
"name": "free_space", | ||
"getval": '''(?P<total_bytes>\d+)\skbytes\stotal\s\((?P<free_bytes>\d+)\skbytes\sfree\)''', | ||
"result": | ||
{ "total_bytes": "{{ total_bytes }}", "free_bytes": "{{ free_bytes }}" }, | ||
}, | ||
] | ||
# fmt: on |
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,10 @@ | ||
# fmt: off | ||
[ | ||
{ | ||
"name": "free_space", | ||
"getval": '''(?P<total_bytes>\d+)\sbytes\sfree''', | ||
"result": | ||
{ "total_bytes": "{{ total_bytes }}", "free_bytes": "{{ free_bytes }}" }, | ||
}, | ||
] | ||
# fmt: on |
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 |
---|---|---|
@@ -1,3 +1,19 @@ | ||
--- | ||
- name: Set supported platform list | ||
ansible.builtin.set_fact: | ||
supported_cli_restore: | ||
- "junos" | ||
- "eos" | ||
supported_plugin_restore: | ||
- "nxos" | ||
- "iosxr" | ||
- "ios" | ||
network_os: "{{ ansible_network_os.split('.')[2] }}" | ||
|
||
- name: Invoke backup task | ||
ansible.builtin.include_tasks: includes/cli_restore.yaml | ||
ansible.builtin.include_tasks: "includes/cli_restore.yaml" | ||
when: network_os not in supported_cli_restore | ||
|
||
- name: Invoke cli specific backup task | ||
ansible.builtin.include_tasks: "includes/cli_restore_config.yaml" | ||
when: network_os not in supported_plugin_restore |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
--- | ||
- name: Prepare appliance for restore | ||
ansible.builtin.debug: | ||
msg: | ||
- "Task to prepare appliance for restore operation" | ||
|
||
- name: Overwrite startup config - archive | ||
cisco.ios.ios_config: | ||
lines: | ||
- "archive" | ||
|
||
- name: Dir the flash | ||
cisco.ios.ios_command: | ||
commands: | ||
- command: "dir" |
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,5 @@ | ||
--- | ||
- name: Prepare appliance for restore | ||
ansible.builtin.debug: | ||
msg: | ||
- "Task to prepare appliance for restore operation" |
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,5 @@ | ||
--- | ||
- name: Prepare appliance for restore | ||
ansible.builtin.debug: | ||
msg: | ||
- "Task to prepare appliance for restore operation" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to be updated with platform-specific releases