4ebe69f02d9710441547a4c6b9e28abe0417b92f
[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: support new parameter swToBeInstalled\r
26     set_fact:\r
27       sw_to_be_installed: "{{swToBeInstalled}}"\r
28     when: swToBeInstalled is defined\r
29 \r
30   - name: check if swToBeInstalled is empty\r
31     fail:\r
32     when: swToBeInstalled is defined and sw_to_be_installed | length == 0\r
33 \r
34   - name: support new parameter swVersionToBeActivated\r
35     set_fact:\r
36       sw_version_to_be_activated: "{{swVersionToBeActivated}}"\r
37     when: swVersionToBeActivated is defined\r
38 \r
39   - name: execute downloadNESw operation\r
40     shell: ./swm/downloadNESw --swToBeDownloaded {{sw_to_be_downloaded}} --neIdentifier {{ne_identifier}}\r
41     register: download_result\r
42 \r
43   - name: parse response of downloadNESw\r
44     set_fact:\r
45       download_response: "{{ download_result.stdout | from_json }}"\r
46     when: swToBeInstalled is not defined\r
47 \r
48   - name: fetch file of Notification notifyDownloadNESwStatusChanged\r
49     fetch:\r
50       dest: "{{inventory_dir}}"\r
51       src: "/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}"\r
52     when: swToBeInstalled is not defined\r
53 \r
54   - name: read contents of Notification notifyDownloadNESwStatusChanged\r
55     set_fact:\r
56       download_notification: "{{ lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}') | from_json }}"\r
57     when: swToBeInstalled is not defined\r
58 \r
59   - name: delete file of Notification notifyDownloadNESwStatusChanged\r
60     local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent\r
61     when: swToBeInstalled is not defined\r
62 \r
63   - name: set downloadedNESwInfo\r
64     set_fact:\r
65       downloaded_ne_sw_info: "{{ download_notification.downloadedNESwInfo }}"\r
66     when: swToBeInstalled is not defined\r
67 \r
68   - name: execute installNESw operation\r
69     shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}\r
70     register: install_result\r
71     with_items: "{{ downloaded_ne_sw_info | default([]) }}"\r
72 \r
73   - name: execute installNESw operation using new parameter\r
74     shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}\r
75     register: install_result_new\r
76     with_items: "{{ sw_to_be_installed | default([]) }}"\r
77 \r
78   - name: unify install result\r
79     set_fact:\r
80       install_result: "{{ install_result_new }}"\r
81     when: swToBeInstalled is defined\r
82 \r
83   - name: set install results list\r
84     set_fact:\r
85       install_results_list: "{{ install_result.results }}"\r
86     when: swVersionToBeActivated is not defined\r
87 \r
88   - name: parse responses of all the installNESws\r
89     set_fact:\r
90       install_responses: "{{ install_responses | default([]) + [item.stdout | from_json] }}"\r
91     with_items: "{{ install_results_list | default([]) }}"\r
92 \r
93   - name: fetch files of all the Notifications notifyInstallNESwStatusChanged\r
94     fetch:\r
95       dest: "{{inventory_dir}}"\r
96       src: "/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}"\r
97     with_items: "{{ install_responses | default([]) }}"\r
98 \r
99   - name: read contents of all the Notifications notifyInstallNESwStatusChanged\r
100     set_fact:\r
101       install_notifications: "{{ install_notifications | default([]) + [lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}') | from_json] }}"\r
102     with_items: "{{ install_responses | default([]) }}"\r
103 \r
104   - name: delete files of all the Notifications notifyInstallNESwStatusChanged\r
105     local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}" state=absent\r
106     with_items: "{{ install_responses | default([]) }}"\r
107 \r
108   - name: parse all the installed NE SW info\r
109     set_fact:\r
110       installed_ne_sw_info: "{{ installed_ne_sw_info | default([]) + item.installedNESwInfo }}"\r
111     with_items: "{{ install_notifications | default([]) }}"\r
112 \r
113   - name: execute activateNESw operation\r
114     shell: ./swm/activateNESw --swVersionToBeActivated {{item}} --neIdentifier {{ne_identifier}}\r
115     register: activate_result\r
116     with_items: "{{ installed_ne_sw_info | default([]) }}"\r
117 \r
118   - name: execute activateNESw operation using new parameter\r
119     shell: ./swm/activateNESw --swVersionToBeActivated {{sw_version_to_be_activated}} --neIdentifier {{ne_identifier}}\r
120     register: activate_result_new\r
121     when: swVersionToBeActivated is defined\r
122 \r
123   - name: unify activate result\r
124     set_fact:\r
125       activate_result: "{{ activate_result_new }}"\r
126     when: swVersionToBeActivated is defined\r
127 \r