/
upgrade.yml
66 lines (59 loc) · 1.65 KB
/
upgrade.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
- name: Upgrade a Cisco IOS router
hosts: csr
tasks:
- name: GATHERING FACTS
ios_facts:
gather_subset: hardware
provider: "{{cli}}"
tags: always
- name: COPYING IMAGE TO DEVICE FLASH
ntc_file_copy:
platform: cisco_ios_ssh
local_file: images/{{ new_image }}
host: "{{ inventory_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
when: ansible_net_version != "{{version}}"
tags: copy
- name: SETTING BOOT IMAGE
ios_config:
lines:
- no boot system
- boot system flash bootflash:{{new_image}}
provider: "{{cli}}"
host: "{{ inventory_hostname }}"
when: ansible_net_version != "{{version}}"
tags: install
- name: SAVING CONFIGS
ntc_save_config:
platform: cisco_ios_ssh
host: "{{ inventory_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
local_file: backup/{{ inventory_hostname }}.cfg
when: ansible_net_version != "{{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 != "{{version}}"
tags: reload
- name: VERIFYING CONNECTIVITY
wait_for:
port: 22
host: "{{inventory_hostname}}"
timeout: 300
- ios_command:
commands: ping 8.8.4.4
provider: "{{cli}}"
wait_for:
- result[0] contains "!!!"
register: result
failed_when: "not '!!!' in result.stdout[0]"
tags: verify