X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=sdnc-a1-controller%2Foam%2Finstallation%2Fansible-server%2Fsrc%2Fmain%2FPlaybooks%2Fansible_huawei_postcheck%400.01.yml;fp=sdnc-a1-controller%2Foam%2Finstallation%2Fansible-server%2Fsrc%2Fmain%2FPlaybooks%2Fansible_huawei_postcheck%400.01.yml;h=b9b1ab81ee1f974bcdd9f7a60d362ef0a5ea52ec;hb=b6fe5a1bbad372357f6b441e1657dd8bbe48dc1a;hp=0000000000000000000000000000000000000000;hpb=4e0c72d8a2570e256911eab7cc34f770a1aa327a;p=nonrtric.git diff --git a/sdnc-a1-controller/oam/installation/ansible-server/src/main/Playbooks/ansible_huawei_postcheck@0.01.yml b/sdnc-a1-controller/oam/installation/ansible-server/src/main/Playbooks/ansible_huawei_postcheck@0.01.yml new file mode 100644 index 00000000..b9b1ab81 --- /dev/null +++ b/sdnc-a1-controller/oam/installation/ansible-server/src/main/Playbooks/ansible_huawei_postcheck@0.01.yml @@ -0,0 +1,41 @@ +--- +- hosts: all + tasks: + - name: create a temporary file for additional data + file: + path: /tmp/tmp-{{Id}} + state: touch + + - name: prepare additional data + shell: echo {{additionalData}} > /tmp/tmp-{{Id}} + + - name: execute post-check operation + shell: ./swm/upgrade-post-check {{pnfId}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} /tmp/tmp-{{Id}} + ignore_errors: yes + register: postcheck_result + + - name: write output to file + local_action: copy content="{{postcheck_result.stdout}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt" + when: postcheck_result.stdout != "" + + - name: remove the temporary file + file: + path: /tmp/tmp-{{Id}} + state: absent + + - name: build error message + set_fact: + err_msg: + "reason": "{{postcheck_result.stderr}}" + "result": "Failure" + when: postcheck_result is failed and postcheck_result.stdout == "" and postcheck_result.stderr != "" + + - name: write error message to file + local_action: copy content="{{err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt" + when: postcheck_result is failed and postcheck_result.stdout == "" and postcheck_result.stderr != "" + + - name: use result of post-check as the result of Playbook + fail: + msg: "{{postcheck_result.stderr}}" + when: postcheck_result is failed +