--- /dev/null
+---\r
+- hosts: all\r
+ tasks:\r
+\r
+ - name: compatible with parameter targetSwVersion\r
+ set_fact:\r
+ sw_to_be_downloaded: "{{targetSwVersion}}"\r
+ when: targetSwVersion is defined\r
+\r
+ - name: support new parameter swToBeDownloaded\r
+ set_fact:\r
+ sw_to_be_downloaded: "{{swToBeDownloaded}}"\r
+ when: swToBeDownloaded is defined\r
+\r
+ - name: compatible with parameter pnfId\r
+ set_fact:\r
+ ne_identifier: "{{pnfId}}"\r
+ when: pnfId is defined\r
+\r
+ - name: support new parameter neIdentifier\r
+ set_fact:\r
+ ne_identifier: "{{neIdentifier}}"\r
+ when: neIdentifier is defined\r
+\r
+ - name: support new parameter swToBeInstalled\r
+ set_fact:\r
+ sw_to_be_installed: "{{swToBeInstalled}}"\r
+ when: swToBeInstalled is defined\r
+\r
+ - name: check if swToBeInstalled is empty\r
+ fail:\r
+ when: swToBeInstalled is defined and sw_to_be_installed | length == 0\r
+\r
+ - name: support new parameter swVersionToBeActivated\r
+ set_fact:\r
+ sw_version_to_be_activated: "{{swVersionToBeActivated}}"\r
+ when: swVersionToBeActivated is defined\r
+\r
+ - name: execute downloadNESw operation\r
+ shell: ./swm/downloadNESw --swToBeDownloaded {{sw_to_be_downloaded}} --neIdentifier {{ne_identifier}}\r
+ ignore_errors: yes\r
+ register: download_result\r
+\r
+ - name: build error message for downloadNESw\r
+ set_fact:\r
+ download_err_msg:\r
+ "reason": "downloadNESw failure"\r
+ "result": "Failure"\r
+ when: download_result is failed\r
+\r
+ - name: write error message to file for downloadNESw\r
+ local_action: copy content="{{download_err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
+ when: download_result is failed\r
+\r
+ - name: use result of downloadNESw as the result of Playbook\r
+ fail:\r
+ msg: "{{download_err_msg}}"\r
+ when: download_result is failed\r
+\r
+ - name: parse response of downloadNESw\r
+ set_fact:\r
+ download_response: "{{ download_result.stdout | from_json }}"\r
+ when: swToBeInstalled is not defined\r
+\r
+ - name: fetch file of Notification notifyDownloadNESwStatusChanged\r
+ fetch:\r
+ dest: "{{inventory_dir}}"\r
+ src: "/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}"\r
+ when: swToBeInstalled is not defined\r
+\r
+ - name: read contents of Notification notifyDownloadNESwStatusChanged\r
+ set_fact:\r
+ download_notification: "{{ lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}') | from_json }}"\r
+ when: swToBeInstalled is not defined\r
+\r
+ - name: delete file of Notification notifyDownloadNESwStatusChanged\r
+ local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent\r
+ when: swToBeInstalled is not defined\r
+\r
+ - name: set downloadedNESwInfo\r
+ set_fact:\r
+ downloaded_ne_sw_info: "{{ download_notification.downloadedNESwInfo }}"\r
+ when: swToBeInstalled is not defined\r
+\r
+ - name: execute installNESw operation\r
+ shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}\r
+ ignore_errors: yes\r
+ register: install_result\r
+ with_items: "{{ downloaded_ne_sw_info | default([]) }}"\r
+\r
+ - name: execute installNESw operation using new parameter\r
+ shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}\r
+ ignore_errors: yes\r
+ register: install_result_new\r
+ with_items: "{{ sw_to_be_installed | default([]) }}"\r
+\r
+ - name: unify install result\r
+ set_fact:\r
+ install_result: "{{ install_result_new }}"\r
+ when: swToBeInstalled is defined\r
+\r
+ - name: build error message for installNESw\r
+ set_fact:\r
+ install_err_msg:\r
+ "reason": "installNESw failure"\r
+ "result": "Failure"\r
+ when: install_result is failed\r
+\r
+ - name: write error message to file for installNESw\r
+ local_action: copy content="{{install_err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
+ when: install_result is failed\r
+\r
+ - name: use result of installNESw as the result of Playbook\r
+ fail:\r
+ msg: "{{install_err_msg}}"\r
+ when: install_result is failed\r
+\r
+ - name: set install results list\r
+ set_fact:\r
+ install_results_list: "{{ install_result.results }}"\r
+ when: swVersionToBeActivated is not defined\r
+\r
+ - name: parse responses of all the installNESws\r
+ set_fact:\r
+ install_responses: "{{ install_responses | default([]) + [item.stdout | from_json] }}"\r
+ with_items: "{{ install_results_list | default([]) }}"\r
+\r
+ - name: fetch files of all the Notifications notifyInstallNESwStatusChanged\r
+ fetch:\r
+ dest: "{{inventory_dir}}"\r
+ src: "/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}"\r
+ with_items: "{{ install_responses | default([]) }}"\r
+\r
+ - name: read contents of all the Notifications notifyInstallNESwStatusChanged\r
+ set_fact:\r
+ install_notifications: "{{ install_notifications | default([]) + [lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}') | from_json] }}"\r
+ with_items: "{{ install_responses | default([]) }}"\r
+\r
+ - name: delete files of all the Notifications notifyInstallNESwStatusChanged\r
+ local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}" state=absent\r
+ with_items: "{{ install_responses | default([]) }}"\r
+\r
+ - name: parse all the installed NE SW info\r
+ set_fact:\r
+ installed_ne_sw_info: "{{ installed_ne_sw_info | default([]) + item.installedNESwInfo }}"\r
+ with_items: "{{ install_notifications | default([]) }}"\r
+\r
+ - name: execute activateNESw operation\r
+ shell: ./swm/activateNESw --swVersionToBeActivated {{item}} --neIdentifier {{ne_identifier}}\r
+ ignore_errors: yes\r
+ register: activate_result\r
+ with_items: "{{ installed_ne_sw_info | default([]) }}"\r
+\r
+ - name: execute activateNESw operation using new parameter\r
+ shell: ./swm/activateNESw --swVersionToBeActivated {{sw_version_to_be_activated}} --neIdentifier {{ne_identifier}}\r
+ ignore_errors: yes\r
+ register: activate_result_new\r
+ when: swVersionToBeActivated is defined\r
+\r
+ - name: unify activate result\r
+ set_fact:\r
+ activate_result: "{{ activate_result_new }}"\r
+ when: swVersionToBeActivated is defined\r
+\r
+ - name: build error message for activateNESw\r
+ set_fact:\r
+ activate_err_msg:\r
+ "reason": "activateNESw failure"\r
+ "result": "Failure"\r
+ when: activate_result is failed\r
+\r
+ - name: write error message to file for activateNESw\r
+ local_action: copy content="{{activate_err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
+ when: activate_result is failed\r
+\r
+ - name: use result of activateNESw as the result of Playbook\r
+ fail:\r
+ msg: "{{activate_err_msg}}"\r
+ when: activate_result is failed\r
+\r
+ - name: build success message for activateNESw\r
+ set_fact:\r
+ activate_success_msg:\r
+ "result": "Success"\r
+ when: activate_result is not failed\r
+\r
+ - name: write success message to file for activateNESw\r
+ local_action: copy content="{{activate_success_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
+ when: activate_result is not failed\r
+\r