Backup Config on Mikrotik RouterOS - Ansible Network community.routeros

Поділитися
Вставка
  • Опубліковано 27 жов 2024

КОМЕНТАРІ • 9

  • @fikriardiansyah9185
    @fikriardiansyah9185 3 місяці тому

    Let say the backup is running smoothly, is there a way to delete the backup configuration automatically that is more than a month old?

  • @GenerlAce
    @GenerlAce Рік тому

    Is there a way to achieve this and change the default ssh port from 22 to something else? ive tried editing the inventory and it still looks for 22.

    • @BertonLuca
      @BertonLuca  Рік тому

      Use the "ansible_port: 8888" variable in your Ansible Inventory to set the 8888 port

  • @AlexanderF70
    @AlexanderF70 2 роки тому

    Very good!!! thx

    • @BertonLuca
      @BertonLuca  2 роки тому

      Glad you like it! See us on Ansible Pilot

  • @sinazangeneh638
    @sinazangeneh638 Рік тому

    i am getting an error
    ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
    JSON: Expecting value: line 1 column 1 (char 0)
    Syntax Error while loading YAML.
    did not find expected key
    The error appears to be in '/home/sina/Desktop/Ansible-Backup/backup_mikrotik.yml': line 14, column 4, but may
    be elsewhere in the file depending on the exact syntax problem.
    The offending line appears to be:
    - name: Backup
    ^ here
    my backup_mikrotik.yml is :
    ---
    - name: Backup Mikrotik
    hosts: mikrotik
    gather_facts: false
    vars:
    backup_dir: "/home/sina/Desktop/Ansible-Backup/Backup"
    tasks:
    - name: Export
    ansible.builtin.shell: >-
    sshpass -p '{{ ansible_password }}' ssh -o StrictHostKeyChecking=no {{ ansible_user }}@{{ inventory_hostname }} /export
    register: export
    delegate_to: localhost
    - name: Backup
    ansible.builtin.copy:
    content: "{{ export.stdout }}"
    dest: "{{ backup_dir }}/{{ inventory_hostname }}_config.{{ lookup('pipe', 'date +%Y-%m-%d@%H:%M:%S') }}"
    when: export is defined
    delegate_to: localhost

    • @TheDoblink
      @TheDoblink Рік тому

      Me too. Did yo find where is the problem?

  • @damaralekkers
    @damaralekkers 2 роки тому

    I am getting an error
    (fatal: [x.x.x.x -> localhost]: FAILED! => {"changed": true, "cmd": "sshpass -p 220 'X' ssh -o StrictHostkeyChecking=no U@x.x.x.x /export", "delta": "0:00:00.010744", "end": "2022-05-18 11:24:36.594021", "msg": "non-zero return code", "rc": 3, "start": "2022-05-18 11:24:36.583277", "stderr": "sshpass: Failed to run command: No such file or directory", "stderr_lines": ["sshpass: Failed to run command: No such file or directory"], "stdout": "", "stdout_lines": []})
    dont mind x replaced the IP with it.
    Should I changing something in the inventory_hostname ?
    I am New to ansible.
    Running on Ubuntu 20.04

    • @BertonLuca
      @BertonLuca  2 роки тому

      Hello Sir, you need to install the "sshpass" utility in your system. www.redhat.com/sysadmin/ssh-automation-sshpass