From de15c462cf53089d304c40c762dfdd8862ab3f8b Mon Sep 17 00:00:00 2001 From: Ganesh B Nalawade Date: Thu, 4 Oct 2018 17:19:28 +0530 Subject: [PATCH] Add rescue function support * Add task for rescue function * Update rescue function doc --- README.md | 1 + docs/load.md | 2 +- docs/rescue.md | 89 +++++++++++++++++++++++++++++++++++++++++++ meta/rescue_spec.yaml | 31 +++++++++++++++ tasks/main.yml | 1 + tasks/rescue.yaml | 9 +++++ 6 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 docs/rescue.md create mode 100644 meta/rescue_spec.yaml create mode 100644 tasks/rescue.yaml diff --git a/README.md b/README.md index 61b1554..fe76393 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/load.md b/docs/load.md index 29a196d..10a9fa7 100644 --- a/docs/load.md +++ b/docs/load.md @@ -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 diff --git a/docs/rescue.md b/docs/rescue.md new file mode 100644 index 0000000..544b007 --- /dev/null +++ b/docs/rescue.md @@ -0,0 +1,89 @@ +# Save and Load rescue configuration into device + +The `config_manager/rescue` function provides a means to save a know good running configuration +as a rescue configuration and rollback the current device configuration to 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. + +## 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. + +``` +- 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 + +In order to load the resuce configuration, the function as before but adds the +value `config_manager_load_rescue_config: yes` to the playbook to indicate that the configuration should +be rollbacked to te the resuce configuration. + +Note: Take caution when doing rescue configuration load 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 +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 +checkpoint that is already set. + +The default value is `False` + +## Notes + +None diff --git a/meta/rescue_spec.yaml b/meta/rescue_spec.yaml new file mode 100644 index 0000000..c6fc54e --- /dev/null +++ b/meta/rescue_spec.yaml @@ -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 + 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 + 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 diff --git a/tasks/main.yml b/tasks/main.yml index b819523..e920171 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,6 +11,7 @@ - load - save - noop + - rescue - name: validate the requested function is supported fail: diff --git a/tasks/rescue.yaml b/tasks/rescue.yaml new file mode 100644 index 0000000..77b764b --- /dev/null +++ b/tasks/rescue.yaml @@ -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