From 8e5c1377eb889b22996fe3ba76e82aa41032ec00 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 18 Mar 2026 15:49:20 +0000 Subject: [PATCH] Update mikrotikbackup_clean.yml --- mikrotikbackup_clean.yml | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/mikrotikbackup_clean.yml b/mikrotikbackup_clean.yml index 38c64b8..45dfb14 100644 --- a/mikrotikbackup_clean.yml +++ b/mikrotikbackup_clean.yml @@ -1,4 +1,4 @@ -- name: Backup MikroTik config (text export only) +- name: Backup and/or Upgrade MikroTik hosts: mikrotik_routers gather_facts: no @@ -8,17 +8,7 @@ tasks: # ---------------------------- - # Ensure local backup directory - # ---------------------------- - - name: Ensure local backup directory exists - ansible.builtin.file: - path: "{{ backup_dir }}" - state: directory - mode: "0755" - delegate_to: localhost - - # ---------------------------- - # Get router identity + # Always: identity + timestamp # ---------------------------- - name: Get router identity community.routeros.command: @@ -31,37 +21,43 @@ router_name: "{{ identity_raw.stdout[0].split(': ')[1] | trim }}" tags: always - # ---------------------------- - # Timestamp - # ---------------------------- - name: Get timestamp ansible.builtin.command: date +%Y-%m-%d_%H-%M-%S register: date_out delegate_to: localhost + tags: always - name: Set timestamp fact set_fact: ts: "{{ date_out.stdout }}" + tags: always # ---------------------------- - # Export config (stable for diff) + # Backup (tag: backup) # ---------------------------- + - name: Ensure local backup directory exists + ansible.builtin.file: + path: "{{ backup_dir }}" + state: directory + mode: "0755" + delegate_to: localhost + tags: backup + - name: Export router config community.routeros.command: commands: /export terse show-sensitive register: export_cfg + tags: backup - # ---------------------------- - # Save export locally - # ---------------------------- - name: Save export locally ansible.builtin.copy: content: "{{ export_cfg.stdout[0] }}" dest: "{{ backup_dir }}/{{ router_name }}-{{ ts }}.rsc" delegate_to: localhost + tags: backup # ---------------------------- - # Upgrade router (tag: upgraded) + # Upgrade (tag: upgrade) # ---------------------------- - name: Check current and latest available package versions community.routeros.command: