5 - name: compatible with parameter targetSwVersion
\r
7 sw_to_be_downloaded: "{{targetSwVersion}}"
\r
8 when: targetSwVersion is defined
\r
10 - name: support new parameter swToBeDownloaded
\r
12 sw_to_be_downloaded: "{{swToBeDownloaded}}"
\r
13 when: swToBeDownloaded is defined
\r
15 - name: compatible with parameter pnfId
\r
17 ne_identifier: "{{pnfId}}"
\r
18 when: pnfId is defined
\r
20 - name: support new parameter neIdentifier
\r
22 ne_identifier: "{{neIdentifier}}"
\r
23 when: neIdentifier is defined
\r
25 - name: support new parameter swToBeInstalled
\r
27 sw_to_be_installed: "{{swToBeInstalled}}"
\r
28 when: swToBeInstalled is defined
\r
30 - name: check if swToBeInstalled is empty
\r
32 when: swToBeInstalled is defined and sw_to_be_installed | length == 0
\r
34 - name: support new parameter swVersionToBeActivated
\r
36 sw_version_to_be_activated: "{{swVersionToBeActivated}}"
\r
37 when: swVersionToBeActivated is defined
\r
39 - name: execute downloadNESw operation
\r
40 shell: ./swm/downloadNESw --swToBeDownloaded {{sw_to_be_downloaded}} --neIdentifier {{ne_identifier}}
\r
42 register: download_result
\r
44 - name: build error message for downloadNESw
\r
47 "reason": "downloadNESw failure"
\r
49 when: download_result is failed
\r
51 - name: write error message to file for downloadNESw
\r
52 local_action: copy content="{{download_err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
\r
53 when: download_result is failed
\r
55 - name: use result of downloadNESw as the result of Playbook
\r
57 msg: "{{download_err_msg}}"
\r
58 when: download_result is failed
\r
60 - name: parse response of downloadNESw
\r
62 download_response: "{{ download_result.stdout | from_json }}"
\r
63 when: swToBeInstalled is not defined
\r
65 - name: fetch file of Notification notifyDownloadNESwStatusChanged
\r
67 dest: "{{inventory_dir}}"
\r
68 src: "/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}"
\r
69 when: swToBeInstalled is not defined
\r
71 - name: read contents of Notification notifyDownloadNESwStatusChanged
\r
73 download_notification: "{{ lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}') | from_json }}"
\r
74 when: swToBeInstalled is not defined
\r
76 - name: delete file of Notification notifyDownloadNESwStatusChanged
\r
77 local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent
\r
78 when: swToBeInstalled is not defined
\r
80 - name: set downloadedNESwInfo
\r
82 downloaded_ne_sw_info: "{{ download_notification.downloadedNESwInfo }}"
\r
83 when: swToBeInstalled is not defined
\r
85 - name: execute installNESw operation
\r
86 shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}
\r
88 register: install_result
\r
89 with_items: "{{ downloaded_ne_sw_info | default([]) }}"
\r
91 - name: execute installNESw operation using new parameter
\r
92 shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}
\r
94 register: install_result_new
\r
95 with_items: "{{ sw_to_be_installed | default([]) }}"
\r
97 - name: unify install result
\r
99 install_result: "{{ install_result_new }}"
\r
100 when: swToBeInstalled is defined
\r
102 - name: build error message for installNESw
\r
105 "reason": "installNESw failure"
\r
106 "result": "Failure"
\r
107 when: install_result is failed
\r
109 - name: write error message to file for installNESw
\r
110 local_action: copy content="{{install_err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
\r
111 when: install_result is failed
\r
113 - name: use result of installNESw as the result of Playbook
\r
115 msg: "{{install_err_msg}}"
\r
116 when: install_result is failed
\r
118 - name: set install results list
\r
120 install_results_list: "{{ install_result.results }}"
\r
121 when: swVersionToBeActivated is not defined
\r
123 - name: parse responses of all the installNESws
\r
125 install_responses: "{{ install_responses | default([]) + [item.stdout | from_json] }}"
\r
126 with_items: "{{ install_results_list | default([]) }}"
\r
128 - name: fetch files of all the Notifications notifyInstallNESwStatusChanged
\r
130 dest: "{{inventory_dir}}"
\r
131 src: "/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}"
\r
132 with_items: "{{ install_responses | default([]) }}"
\r
134 - name: read contents of all the Notifications notifyInstallNESwStatusChanged
\r
136 install_notifications: "{{ install_notifications | default([]) + [lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}') | from_json] }}"
\r
137 with_items: "{{ install_responses | default([]) }}"
\r
139 - name: delete files of all the Notifications notifyInstallNESwStatusChanged
\r
140 local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}" state=absent
\r
141 with_items: "{{ install_responses | default([]) }}"
\r
143 - name: parse all the installed NE SW info
\r
145 installed_ne_sw_info: "{{ installed_ne_sw_info | default([]) + item.installedNESwInfo }}"
\r
146 with_items: "{{ install_notifications | default([]) }}"
\r
148 - name: execute activateNESw operation
\r
149 shell: ./swm/activateNESw --swVersionToBeActivated {{item}} --neIdentifier {{ne_identifier}}
\r
151 register: activate_result
\r
152 with_items: "{{ installed_ne_sw_info | default([]) }}"
\r
154 - name: execute activateNESw operation using new parameter
\r
155 shell: ./swm/activateNESw --swVersionToBeActivated {{sw_version_to_be_activated}} --neIdentifier {{ne_identifier}}
\r
157 register: activate_result_new
\r
158 when: swVersionToBeActivated is defined
\r
160 - name: unify activate result
\r
162 activate_result: "{{ activate_result_new }}"
\r
163 when: swVersionToBeActivated is defined
\r
165 - name: build error message for activateNESw
\r
168 "reason": "activateNESw failure"
\r
169 "result": "Failure"
\r
170 when: activate_result is failed
\r
172 - name: write error message to file for activateNESw
\r
173 local_action: copy content="{{activate_err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
\r
174 when: activate_result is failed
\r
176 - name: use result of activateNESw as the result of Playbook
\r
178 msg: "{{activate_err_msg}}"
\r
179 when: activate_result is failed
\r
181 - name: build success message for activateNESw
\r
183 activate_success_msg:
\r
184 "result": "Success"
\r
185 when: activate_result is not failed
\r
187 - name: write success message to file for activateNESw
\r
188 local_action: copy content="{{activate_success_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
\r
189 when: activate_result is not failed
\r