From 051f95d458458e01440083fc1ec4ac1470b4b8c3 Mon Sep 17 00:00:00 2001 From: jakub Date: Sat, 19 Jul 2025 16:37:35 +0000 Subject: [PATCH] Update mikrotikbackup.yml --- mikrotikbackup.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/mikrotikbackup.yml b/mikrotikbackup.yml index 19459de..da324d8 100644 --- a/mikrotikbackup.yml +++ b/mikrotikbackup.yml @@ -13,7 +13,10 @@ delegate_to: localhost - name: Get router identity - ansible.builtin.shell: ssh -o StrictHostKeyChecking=no {{ ansible_user }}@{{ ansible_host }} -p {{ ansible_port }} "/system identity print" + ansible.builtin.shell: > + ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no + {{ ansible_user }}@{{ ansible_host }} -p {{ ansible_port }} + "/system identity print" register: system_identity delegate_to: localhost @@ -31,7 +34,10 @@ current_date: "{{ date_output.stdout }}" - name: Export router config - ansible.builtin.shell: ssh -o StrictHostKeyChecking=no {{ ansible_user }}@{{ ansible_host }} -p {{ ansible_port }} "/export" + ansible.builtin.shell: > + ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no + {{ ansible_user }}@{{ ansible_host }} -p {{ ansible_port }} + "/export" register: export_output delegate_to: localhost @@ -42,13 +48,23 @@ delegate_to: localhost - name: Create binary backup on router - ansible.builtin.shell: ssh -o StrictHostKeyChecking=no {{ ansible_user }}@{{ ansible_host }} -p {{ ansible_port }} "/system backup save name={{ router_name }}-{{ current_date }}-backup" + ansible.builtin.shell: > + ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no + {{ ansible_user }}@{{ ansible_host }} -p {{ ansible_port }} + "/system backup save name={{ router_name }}-{{ current_date }}-backup" delegate_to: localhost - name: Download binary backup - ansible.builtin.shell: scp -o StrictHostKeyChecking=no -P {{ ansible_port }} {{ ansible_user }}@{{ ansible_host }}:{{ router_name }}-{{ current_date }}-backup.backup output/ + ansible.builtin.shell: > + scp -o ConnectTimeout=10 -o StrictHostKeyChecking=no + -P {{ ansible_port }} + {{ ansible_user }}@{{ ansible_host }}:{{ router_name }}-{{ current_date }}-backup.backup + output/ delegate_to: localhost - name: Remove backup file from router - ansible.builtin.shell: ssh -o StrictHostKeyChecking=no {{ ansible_user }}@{{ ansible_host }} -p {{ ansible_port }} "/file remove {{ router_name }}-{{ current_date }}-backup.backup" + ansible.builtin.shell: > + ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no + {{ ansible_user }}@{{ ansible_host }} -p {{ ansible_port }} + "/file remove {{ router_name }}-{{ current_date }}-backup.backup" delegate_to: localhost