43 lines
1.5 KiB
YAML
43 lines
1.5 KiB
YAML
---
|
|
- name: set device type
|
|
set_fact:
|
|
devtype: >
|
|
{% if 'routeros' in group_names %}routeros
|
|
{% elif 'ciscoasa' in group_names %}asa
|
|
{% elif 'ciscoios' in group_names %}ios
|
|
{% elif 'hpcomware' in group_names %}comware
|
|
{% else %}undefined
|
|
{% endif %}
|
|
|
|
- name: backup
|
|
ansible.builtin.command:
|
|
cmd: >
|
|
{{ routerbackup_bin }}/routerbackup --difflog --diffprint --noerrors
|
|
--logfile {{ routerbackup_log }} --backupdir {{ routerbackup_dir }} --type {{ devtype }}
|
|
--host {{ inventory_hostname }} --address {{ ansible_host }} --user {{ ansible_user }}
|
|
{% if ansible_private_key_file is defined %} --sshkey {{ ansible_private_key_file }}{% endif %}
|
|
{% if ansible_ssh_pass is defined %} --password {{ ansible_ssh_pass }}{% endif %}
|
|
delegate_to: localhost
|
|
changed_when: false
|
|
register: diff
|
|
|
|
- name: create empty diff file
|
|
copy:
|
|
content: ""
|
|
dest: "{{ routerbackup_diff }}"
|
|
delegate_to: localhost
|
|
run_once: true
|
|
changed_when: false
|
|
when: "routerbackup_diff is defined"
|
|
|
|
- name: fill diff into file
|
|
lineinfile:
|
|
path: "{{ routerbackup_diff }}"
|
|
line: "\n{{ diff.stdout }}\n\n=============================================================================="
|
|
delegate_to: localhost
|
|
when:
|
|
- "routerbackup_diff is defined"
|
|
- "diff.stdout != ''"
|
|
|
|
# vim: set tabstop=2 shiftwidth=2 expandtab smarttab:
|