Untitled

Anonymous
Plain Text
09/18/2025 8:33 AM
809 B
22
Indexable
Never
# On your Ubuntu machine
cat > backup.yml << 'EOF'
---
- hosts: juniper
  gather_facts: yes
  tasks:
    - name: Set timestamp
      set_fact:
        timestamp: "{{ ansible_date_time.date }}_{{ ansible_date_time.time }}"
    
    - name: Backup switch configuration
      junipernetworks.junos.junos_config:
        backup: yes
        backup_options:
          dir_path: ./backups
          filename: "{{ ansible_net_hostname }}-config-{{ timestamp }}.cfg"
      register: backup_result
    
    - name: Show backup details
      debug:
        msg: |
          ✅ Backup completed successfully!
          📁 File: {{ backup_result.backup_path }}
          🖥️  Switch: {{ ansible_net_hostname }}
          📦 Model: {{ ansible_net_model }}
          🏷️  Version: {{ ansible_net_version }}
EOF
Editor is loading...
Leave a Comment