Fix missing payload for DGs and Playbooks of SW upgrade
[sdnc/oam.git] / installation / ansible-server / src / main / Playbooks / ansible_huawei_postcheck@0.01.yml
1 ---\r
2 - hosts: all\r
3   tasks:\r
4   - name: create a temporary file for additional data\r
5     file: \r
6       path: /tmp/tmp-{{Id}}\r
7       state: touch\r
8 \r
9   - name: prepare additional data\r
10     shell: echo {{additionalData}} > /tmp/tmp-{{Id}}\r
11 \r
12   - name: execute post-check operation\r
13     shell: ./swm/upgrade-post-check {{pnfId}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} /tmp/tmp-{{Id}}\r
14     ignore_errors: yes\r
15     register: postcheck_result\r
16 \r
17   - name: write output to file\r
18     local_action: copy content="{{postcheck_result.stdout}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
19     when: postcheck_result.stdout != ""\r
20 \r
21   - name: remove the temporary file\r
22     file:\r
23       path: /tmp/tmp-{{Id}}\r
24       state: absent\r
25 \r
26   - name: build error message\r
27     set_fact:\r
28       err_msg:\r
29         "reason": "{{postcheck_result.stderr}}"\r
30         "result": "Failure"\r
31     when: postcheck_result is failed and postcheck_result.stdout == "" and postcheck_result.stderr != ""\r
32 \r
33   - name: write error message to file\r
34     local_action: copy content="{{err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
35     when: postcheck_result is failed and postcheck_result.stdout == "" and postcheck_result.stderr != ""\r
36 \r
37   - name: use result of post-check as the result of Playbook\r
38     fail:\r
39       msg: "{{postcheck_result.stderr}}"\r
40     when: postcheck_result is failed\r
41 \r