514027268c169074e3268c0e0a863c2129c6ee79
[sdnc/oam.git] / installation / ansible-server / src / main / Playbooks / ansible_huawei_upgrade@0.01.yml
1 ---\r
2 - hosts: all\r
3   tasks:\r
4 \r
5   - name: compatible with parameter targetSwVersion\r
6     set_fact:\r
7       sw_to_be_downloaded: "{{targetSwVersion}}"\r
8     when: targetSwVersion is defined\r
9 \r
10   - name: support new parameter swToBeDownloaded\r
11     set_fact:\r
12       sw_to_be_downloaded: "{{swToBeDownloaded}}"\r
13     when: swToBeDownloaded is defined\r
14 \r
15   - name: compatible with parameter pnfId\r
16     set_fact:\r
17       ne_identifier: "{{pnfId}}"\r
18     when: pnfId is defined\r
19 \r
20   - name: support new parameter neIdentifier\r
21     set_fact:\r
22       ne_identifier: "{{neIdentifier}}"\r
23     when: neIdentifier is defined\r
24 \r
25   - name: execute downloadNESw operation\r
26     shell: ./swm/downloadNESw.sh --swToBeDownloaded {{sw_to_be_downloaded}} --neIdentifier {{ne_identifier}}\r
27     register: download_result\r
28 \r
29   - name: parse response of downloadNESw\r
30     set_fact:\r
31       download_response: "{{ download_result.stdout | from_json }}"\r
32 \r
33   - name: fetch file of Notification notifyDownloadNESwStatusChanged\r
34     fetch:\r
35       dest: /tmp/\r
36       src: /tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}\r
37 \r
38   - name: read contents of Notification notifyDownloadNESwStatusChanged\r
39     set_fact:\r
40       download_notification: "{{ lookup('file', '/tmp/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}') | from_json }}"\r
41 \r
42   - name: delete file of Notification notifyDownloadNESwStatusChanged\r
43     local_action: file path="/tmp/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent\r
44 \r
45   - name: execute installNESw operation\r
46     shell: ./swm/installNESw.sh --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}\r
47     register: install_result\r
48     with_items: "{{ download_notification.downloadedNESwInfo }}"\r
49 \r
50   - name: parse responses of all the installNESws\r
51     set_fact:\r
52       install_responses: "{{ install_responses | default([]) + [item.stdout | from_json] }}"\r
53     with_items: "{{ install_result.results }}"\r
54 \r
55   - name: fetch files of all the Notifications notifyInstallNESwStatusChanged\r
56     fetch:\r
57       dest: /tmp/\r
58       src: /tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}\r
59     with_items: "{{ install_responses }}"\r
60 \r
61   - name: read contents of all the Notifications notifyInstallNESwStatusChanged\r
62     set_fact:\r
63       install_notifications: "{{ install_notifications | default([]) + [lookup('file', '/tmp/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}') | from_json] }}"\r
64     with_items: "{{ install_responses }}"\r
65 \r
66   - name: delete files of all the Notifications notifyInstallNESwStatusChanged\r
67     local_action: file path="/tmp/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}" state=absent\r
68     with_items: "{{ install_responses }}"\r
69 \r
70   - name: parse all the installed NE SW info\r
71     set_fact:\r
72       installed_ne_sw_info: "{{ installed_ne_sw_info | default([]) + item.installedNESwInfo }}"\r
73     with_items: "{{ install_notifications }}"\r
74 \r
75   - name: execute activateNESw operation\r
76     shell: ./swm/activateNESw.sh --swVersionToBeActivated {{item}} --neIdentifier {{ne_identifier}}\r
77     register: activate_result\r
78     with_items: "{{ installed_ne_sw_info }}"\r
79 \r