From 8cdeb6a26e9a61852f37551c633a8e9c830420b0 Mon Sep 17 00:00:00 2001 From: Valentin Gurmeza Date: Fri, 16 Jun 2017 19:46:32 -0700 Subject: [PATCH 1/2] add a sample backup and rollback task to use on production routers --- tasks/backup_recover.yml | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tasks/backup_recover.yml diff --git a/tasks/backup_recover.yml b/tasks/backup_recover.yml new file mode 100644 index 0000000..e1da419 --- /dev/null +++ b/tasks/backup_recover.yml @@ -0,0 +1,52 @@ +--- +################################################################ +# TEMPORARY TASK TO STORE THE ROLLBACK PROCEDURE +####################################################################### + +################################################################### +# create a backup and add a scheduler to rollback if we lose connection +# to the a mikrotik device during the ansible run. +# Place this in the begging of your playbook +##################################################################### +- name: run command module to create a backup + mt_command: + hostname: "{{ mt_hostname }}" + username: "{{ mt_user }}" + password: "{{ mt_pass }}" + command: /system/backup/save + command_arguments: + name: pre_deploy + password: 123 +- name: add rollback scheduler task + mt_system_scheduler: + hostname: "{{ mt_hostname }}" + username: "{{ mt_user }}" + password: "{{ mt_pass }}" + state: present + name: rollback + on_event: /system backup load name=pre_deploy.backup password=123 + interval: 30m + policy: + - password + - reboot + - write + - sensitive + - test + - read + - policy + +################################################################### +# Place this in the end of your mikrotik playbook this will remove the +# rollback scheduler task if the playbook runs succesfully +##################################################################### +- name: remove rollback scheduler task if run succesfull + hosts: govsat + gather_facts: no + connection: local + tasks: + - mt_system_scheduler: + hostname: "{{ mt_hostname }}" + username: "{{ mt_user }}" + password: "{{ mt_pass }}" + state: absent + name: rollback From cc6eb9b76635f1cd99f6057df6ffc3801595accc Mon Sep 17 00:00:00 2001 From: Valentin Gurmeza Date: Wed, 21 Jun 2017 15:42:40 -0700 Subject: [PATCH 2/2] fix spells --- tasks/backup_recover.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tasks/backup_recover.yml b/tasks/backup_recover.yml index e1da419..32f53a8 100644 --- a/tasks/backup_recover.yml +++ b/tasks/backup_recover.yml @@ -1,6 +1,6 @@ --- ################################################################ -# TEMPORARY TASK TO STORE THE ROLLBACK PROCEDURE +# TEMPORARY PLAYBOOK TO STORE THE ROLLBACK PROCEDURE ####################################################################### ################################################################### @@ -17,6 +17,7 @@ command_arguments: name: pre_deploy password: 123 + - name: add rollback scheduler task mt_system_scheduler: hostname: "{{ mt_hostname }}" @@ -37,7 +38,7 @@ ################################################################### # Place this in the end of your mikrotik playbook this will remove the -# rollback scheduler task if the playbook runs succesfully +# rollback scheduler task if the playbook runs successfully ##################################################################### - name: remove rollback scheduler task if run succesfull hosts: govsat