Merge "Update DGs and Playbooks for PNF SW Upgrade"
[sdnc/oam.git] / installation / ansible-server / src / main / Playbooks / ansible_huawei_downloadnesw@0.00.yml
1 ---\r
2 - hosts: all\r
3   tasks:\r
4 \r
5   - name: parameter swToBeDownloaded\r
6     set_fact:\r
7       sw_to_be_downloaded: "{{swToBeDownloaded}}"\r
8     when: swToBeDownloaded is defined\r
9 \r
10   - name: parameter neIdentifier\r
11     set_fact:\r
12       ne_identifier: "{{neIdentifier}}"\r
13     when: neIdentifier is defined\r
14 \r
15   - name: compatible with parameter pnfName\r
16     set_fact:\r
17       ne_identifier: "{{pnfName}}"\r
18     when: neIdentifier is not defined and pnfName is defined\r
19 \r
20   - name: execute downloadNESw operation\r
21     shell: ./swm/downloadNESw --swToBeDownloaded {{sw_to_be_downloaded}} --neIdentifier {{ne_identifier}}\r
22     ignore_errors: yes\r
23     register: download_result\r
24 \r
25   - name: parse response of downloadNESw\r
26     set_fact:\r
27       download_response: "{{ download_result.stdout | from_json }}"\r
28 \r
29   - name: build failure message\r
30     set_fact:\r
31       download_failure_msg: "{{ download_result.stdout }}"\r
32     when: download_result is failed\r
33 \r
34   - name: write failure message to file\r
35     local_action: copy content="{{download_failure_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
36     when: download_result is failed\r
37 \r
38   - name: use result of downloadNESw as the result of Playbook\r
39     fail:\r
40       msg: "{{download_failure_msg}}"\r
41     when: download_result is failed\r
42 \r
43   - name: fetch file of Notification notifyDownloadNESwStatusChanged\r
44     fetch:\r
45       dest: "{{inventory_dir}}"\r
46       src: "/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}"\r
47 \r
48   - name: read contents of Notification notifyDownloadNESwStatusChanged\r
49     set_fact:\r
50       download_notification: "{{ lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}') | from_json }}"\r
51 \r
52   - name: delete file of Notification notifyDownloadNESwStatusChanged\r
53     local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent\r
54 \r
55   - name: build success message\r
56     set_fact:\r
57       download_success_msg:\r
58         "result": "Success"\r
59     when: download_notification.downloadOperationStatus == "NE_SWDOWNLOAD_SUCCESSFUL"\r
60 \r
61   - name: write success message to file\r
62     local_action: copy content="{{download_success_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
63     when: download_notification.downloadOperationStatus == "NE_SWDOWNLOAD_SUCCESSFUL"\r
64 \r