Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- - name: Upgrade a Cisco IOS Device
- hosts: ios_switch
- tasks:
- - name: Gathering Facts
- ios_facts:
- gather_subset: hardware
- provider: "{{ creds_ssh }}"
- tags: always
- - name: Copying image to device flash
- ntc_file_copy:
- platform: cisco_ios_ssh
- local_file: images/{{ image }}
- host: "{{ inventory_hostname }}"
- username: "{{ username }}"
- password: "{{ password }}"
- when: ansible_net_version != "{{ standard_version }}"
- tags: copy
- - name: Setting boot image
- ios_config:
- lines:
- - no boot system
- - boot system flash:{{ image }}
- provider: "{{ creds_ssh }}"
- host: "{{ inventory_hostname }}"
- when: ansible_net_version != "{{ standard_version }}"
- tags: set_boot
- notify: save config
- - name: Backup config
- ntc_save_config:
- platform: cisco_ios_ssh
- host: "{{ inventory_hostname }}"
- username: "{{ username }}"
- password: "{{ password }}"
- local_file: backup/{{ inventory_hostname }}.cfg
- when: ansible_net_version != "{{ standard_version }}"
- tags: backup
- - name: Reloading the device
- ntc_reboot:
- platform: cisco_ios_ssh
- confirm: true
- timer: 2
- host: "{{ inventory_hostname }}"
- username: "{{ username }}"
- password: "{{ password }}"
- when: ansible_net_version != "{{ standard_version }}"
- tags: reload
- - name: Verifying connectivity
- wait_for:
- port: 22
- host: "{{ inventory_hostname }}"
- timeout: 600
- - ios_command:
- commands: ping 8.8.8.8
- provider: "{{ creds_ssh }}"
- wait_for:
- - result[0] contains "!!!"
- register: result
- failed_when: "not '!!!' in result.stdout[0]"
- tags: verify
- handlers:
- - name: save config
- ios_config:
- provider: "{{ creds_ssh }}"
- save_when: always
Add Comment
Please, Sign In to add comment