Untitled
unknown
plain_text
10 months ago
1.2 kB
15
Indexable
---
- name: Backup FSOS switch configuration
hosts: fs_switches
gather_facts: no
vars:
backup_dir: /home/amrc-demopc/fs-backups
switch_user: admin
switch_pass: "QfvxSVHq"
ssh_opts: >
-oKexAlgorithms=+diffie-hellman-group14-sha1
-oHostKeyAlgorithms=+ssh-dss
-oPubkeyAcceptedAlgorithms=+ssh-dss
-oPubkeyAcceptedKeyTypes=+ssh-dss
-oMACs=+hmac-sha1
-oCiphers=+aes128-cbc,aes256-cbc,3des-cbc
-oStrictHostKeyChecking=no
tasks:
- name: Ensure local backup directory exists
ansible.builtin.file:
path: "{{ backup_dir }}"
state: directory
mode: '0755'
delegate_to: localhost
- name: Collect running config via SSH
ansible.builtin.shell: >
sshpass -p "{{ switch_pass }}" ssh {{ ssh_opts }} {{ switch_user }}@{{ inventory_hostname }} "show running-config"
register: running_config
delegate_to: localhost
- name: Save running config to local backup file
ansible.builtin.copy:
content: "{{ running_config.stdout }}"
dest: "{{ backup_dir }}/{{ inventory_hostname }}-{{ ansible_date_time.iso8601_basic }}.cfg"
delegate_to: localhostEditor is loading...
Leave a Comment