-
Notifications
You must be signed in to change notification settings - Fork 1
/
ios upgrades
94 lines (68 loc) · 2.13 KB
/
ios upgrades
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
# Ansible Playbook to upgrade Cisco IOS
- name: Upgrade CISCO IOS
hosts: NTLtest
vars:
upgrade_ios_version: 15.2.4E10b
tasks:
- name: CHECK CURRENT VERSION
ios_facts:
- debug:
msg:
- "Current version is {{ ansible_net_version }}"
- "Upgrade image is 15.2.4E10b"
- debug:
msg:
- "Image is not compliant and will be upgraded"
when: ansible_net_version != upgrade_ios_version
##Delete the old IOS
- name: Delete old ios
ios_command:
commands: delete /force flash:c3750e-universalk9-mz.152-4.E9.bin
## SAVE the Running Config
- name: Save running config
ios_config:
save_when: always
## Copy software to target device
- name: Copy Image // This could take up to 4 minutes
net_put:
src: "/home/jimmy/Downloads/c3750e-universalk9-mz.152-4.E10b.bin"
dest: "flash:c3750e-universalk9-mz.152-4.E10b.bin"
vars:
ansible_command_timeout: 600
## Change the Boot Variable to the new image
- name: Change Boot Variable to new image
ios_config:
commands:
- "boot system flash:c3750e-universalk9-mz.152-4.E10b.bin"
save_when: always
## Reload the device
- name: Reload the Device
cli_command:
command: reload
prompt:
- confirm
answer:
- 'y'
## Wait for Reachability to the device
- name: Wait for device to come back online
wait_for:
host: "{{ inventory_hostname }}"
port: 22
delay: 90
delegate_to: localhost
## Check current image
- name: Check Image Version
ios_facts:
- debug:
msg:
- "Current version is {{ ansible_net_version }}"
- name: ASSERT THAT THE IOS VERSION IS CORRECT
vars:
upgrade_ios_version: 15.2.4E10b
assert:
that:
- upgrade_ios_version == ansible_net_version
- debug:
msg:
- "Software Upgrade has been completed"