Skip to content

Add rescue function support #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ in this role.
* get [[source]](https://github.com/ansible-network/config_manager/blob/devel/tasks/get.yaml) [[docs]](https://github.com/ansible-network/config_manager/blob/devel/docs/get.md)
* load [[source]](https://github.com/ansible-network/config_manager/blob/devel/tasks/load.yaml) [[docs]](https://github.com/ansible-network/config_manager/blob/devel/docs/load.md)
* save [[source]](https://github.com/ansible-network/config_manager/blob/devel/tasks/save.yaml) [[docs]](https://github.com/ansible-network/config_manager/blob/devel/docs/save.md)
* rescue [[source]](https://github.com/ansible-network/config_manager/blob/devel/tasks/rescue.yaml) [[docs]](https://github.com/ansible-network/config_manager/blob/devel/docs/rescue.md)

## License

Expand Down
2 changes: 1 addition & 1 deletion docs/load.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ section for different example of how to push configurations to network devices.

## How to use this function

The examples below demonstate how to use this function in a playbook.
The examples below demonstrate how to use this function in a playbook.

## How to load and merge a configuration

Expand Down
89 changes: 89 additions & 0 deletions docs/rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Save and Load rescue configuration into device
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Save and Load rescue configuration into device
# Save and load a rescue configuration into a device


The `config_manager/rescue` function provides a means to save a know good running configuration
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `config_manager/rescue` function provides a means to save a know good running configuration
The `config_manager/rescue` function provides a means to save a known good running configuration

as a rescue configuration and rollback the current device configuration to rescue configuration
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
as a rescue configuration and rollback the current device configuration to rescue configuration
as a rescue configuration and rollback the current device configuration to the rescue configuration

when required.

The `rescue` function provides some configurable options when rescuing the
configuration on the remote device. See the `How to use this function`
section for different example of how to rescue configuration on network devices.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
section for different example of how to rescue configuration on network devices.
section for different examples of how to rescue configuration on network devices.


## How to use this function

The examples below demonstrate how to use this function in a playbook.

## How to save a rescue configuration checkpoint

Below is an example of how to call the `config_manager/rescue` function to mark the
current running configuration as rescue config.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
current running configuration as rescue config.
current running configuration as the rescue configuration.


```
- hosts: network

roles:
- name: ansible-network.config_manager
function: rescue
config_manager_set_rescue: True
```

### How to load the rescue configuration

The `config_manager/rescue` function also provides support to rollback the current running
configuration to a rescue configuration when required
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
configuration to a rescue configuration when required
configuration to the rescue configuration when required


In order to load the resuce configuration, the function as before but adds the
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In order to load the resuce configuration, the function as before but adds the
In order to load the rescue configuration, add the

value `config_manager_load_rescue_config: yes` to the playbook to indicate that the configuration should
be rollbacked to te the resuce configuration.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
be rollbacked to te the resuce configuration.
be rolled back to the rescue configuration.


Note: Take caution when doing rescue configuration load that you do not
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note: Take caution when doing rescue configuration load that you do not
Note: Take caution when loading the rescue configuration so that you do not

inadvertently replace your access to the device.

```
- hosts: network

roles:
- name: ansible-network.config_manager
function: rescue
config_manager_load_rescue_config: True
```

## How to delete a rescue configuration checkpoint

Below is an example of how to call the `config_manager/rescue` function to delete the
previously set rescue configuration.

```
- hosts: network

roles:
- name: ansible-network.config_manager
function: rescue
config_manager_delete_rescue: True
```

## Arguments

### config_manager_set_rescue

This setting indicates whether or not the to set the current running
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This setting indicates whether or not the to set the current running
This setting indicates whether or not to set the current running

configuration as the rescue configuration.

The default value is `False`

### config_manager_load_rescue_config

This setting indicates whether or not to replace the current configuration
with the rescue configuration.

The default value is `False`

### config_manager_delete_rescue

This setting indicates whether or not the to delete the rescue configuration
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This setting indicates whether or not the to delete the rescue configuration
This setting indicates whether or not to delete the rescue configuration

checkpoint that is already set.

The default value is `False`

## Notes

None
31 changes: 31 additions & 0 deletions meta/rescue_spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
argument_spec:
ansible_network_provider:
description:
- This value is used to determine the correct role to implement the
load_config function. The network device provider role is responsible
for performing the actual implementation of the load_config function.
The specified role must be installed and accesible via the configured
ansible_role_path setting.
required: True

config_manager_set_rescue:
descriptiion:
- This setting indicates whether or not the to set the current running
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- This setting indicates whether or not the to set the current running
- This setting indicates whether or not to set the current running

configuration as the rescue configuration.
type: bool
default: False

config_manager_delete_rescue:
descriptiion:
- This setting indicates whether or not the to delete the rescue configuration
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- This setting indicates whether or not the to delete the rescue configuration
- This setting indicates whether or not to delete the rescue configuration

checkpoint that is already set.
type: bool
default: False

config_manager_load_rescue_config:
descriptiion:
- This setting indicates whether or not to replace the current configuration
with the rescue configuration.
type: bool
default: False
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- load
- save
- noop
- rescue

- name: validate the requested function is supported
fail:
Expand Down
9 changes: 9 additions & 0 deletions tasks/rescue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: validate role spec
validate_role_spec:
spec: rescue_spec.yaml

- name: invoke network provider
include_role:
name: "{{ ansible_network_provider }}"
tasks_from: config_manager/rescue