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