-
Notifications
You must be signed in to change notification settings - Fork 1
/
upgrade_panos_v10.yml
198 lines (170 loc) · 6.04 KB
/
upgrade_panos_v10.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
- hosts: all
connection: local
gather_facts: false
vars:
auth_code: 'your valid VM Auth-Code if unlicensed'
provider:
ip_address: '{{ ip_address }}'
username: '{{ username }}'
password: '{{ password }}'
collections:
- paloaltonetworks.panos
tasks:
- name: Ensure deps are avabilable
# Ensure we have all the right requirements installed in this environment
pip:
name:
- pan-python
- pandevice
- xmltodict
- requests
- requests_toolbelt
- name: Show System Info
# Grab the system info to determine current sw-version
# this will also wait for the device to come on-line
panos_op:
provider: '{{ provider }}'
cmd: 'show system info'
register: system_info
until: system_info is not failed
retries: 30
delay: 60
- set_fact: system_info_json="{{ system_info.stdout | from_json }}"
- name: Show Version
debug: msg="Current Version is {{ system_info_json.response.result.system['sw-version'] }} "
- name: Activate my authcode
# This firewall must be licensed to pull dynamic content and software updates
panos_lic:
provider: '{{ provider }}'
auth_code: '{{ auth_code }}'
register: activate_authcode
- name: Pause for Service Restart
pause:
seconds: 180
when: activate_authcode.changed
- name: Wait for Reboot if necessary
# Installing a license will cause pan software to restart, again wait for a positive API call
panos_op:
provider: '{{ provider }}'
cmd: 'show system info'
register: system_info
until: system_info is not failed
retries: 30
delay: 60
- set_fact: system_info_json="{{ system_info.stdout | from_json }}"
- debug:
msg: "Serial number is {{ system_info_json.response.result.system['serial'] }}"
- debug:
msg: "Software version is {{ system_info_json.response.result.system['sw-version'] }}"
- name: Check latest content
# Get an updated dynamic content list
panos_op:
provider: '{{ provider }}'
cmd: 'request content upgrade check'
register: check
- name: Download latest content
# Download the latest version
panos_op:
provider: '{{ provider }}'
cmd: |
<request><content><upgrade><download>
<latest></latest>
</download></upgrade></content></request>
cmd_is_xml: true
register: download
- name: Check content download result
# wait for this job to finish
panos_op:
provider: '{{ provider }}'
cmd: 'show jobs id {{ (download.stdout | from_json).response.result.job }}'
register: download_job
until: download_job is not failed and (download_job.stdout | from_json).response.result.job.status == 'FIN'
retries: 10
delay: 60
- name: Install latest content
# Content is downloaded and ready, now install it
panos_op:
provider: '{{ provider }}'
cmd: |
<request><content><upgrade><install>
<version>latest</version>
</install></upgrade></content></request>
cmd_is_xml: true
register: install
- name: Check content install result
# again, wait for job to complete
panos_op:
provider: '{{ provider }}'
cmd: 'show jobs id {{ (install.stdout | from_json).response.result.job }}'
register: install_job
until: install_job is not failed and (install_job.stdout | from_json).response.result.job.status == 'FIN'
retries: 10
delay: 60
- name: Download PAN-OS 9.0.0 base image only
# If current version is less than 9.0, download 9.0 base image
panos_software:
provider: '{{ provider }}'
version: '9.0.0'
install: false
restart: false
when: |
system_info_json.response.result.system['sw-version'] is version('9.0.0', '<')
- name: Install PAN-OS 9.0.8
# if current version is less than 9.0.8, then do an upgrade, with no restart
panos_software:
provider: '{{ provider }}'
version: '9.0.8'
install: true
restart: false # fixme - we may need a reboot and wait cycle here as well
when: |
system_info_json.response.result.system['sw-version'] is version('9.0.8', '<')
- name: Download PAN-OS 9.1.0 base image only
# if current version is less than 9.1.0, download 9.1 base image
panos_software:
provider: '{{ provider }}'
version: '9.1.0'
install: false
restart: false
when: |
system_info_json.response.result.system['sw-version'] is version('9.1.0', '<')
- name: Install PAN-OS 9.1.3-h1
# if current version is less than 9.1.2-h1
panos_software:
provider: '{{ provider }}'
version: '9.1.3-h1'
install: true
restart: true
when: |
system_info_json.response.result.system['sw-version'] is version('9.1.3', '<')
- name: Wait for Reboot if necessary
# wait for device to come back online
panos_op:
provider: '{{ provider }}'
cmd: 'show system info'
register: system_info
until: system_info is not failed
retries: 30
delay: 60
- set_fact: system_info_json="{{ system_info.stdout | from_json }}"
- name: Install PAN-OS 10.0.0
# if current version is less than 10.0.0
panos_software:
provider: '{{ provider }}'
version: '10.0.0'
install: true
restart: true
when: |
system_info_json.response.result.system['sw-version'] is version('10.0.0', '<')
- name: Pause for restart
pause:
seconds: 30
- name: Final Reboot Cycle
panos_op:
provider: '{{ provider }}'
cmd: 'show system info'
register: system_info
until: system_info is not failed
retries: 30
delay: 60
- name: Display new software rev
debug: msg="Softare is now {{ (system_info.stdout | from_json).response.result.system['sw-version'] }}"