NonRT-RIC A1 Northbound API
[nonrtric.git] / sdnc-a1-controller / oam / installation / ansible-server / src / main / Playbooks / ansible_huawei_postcheck@0.01.yml
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 (file)
index 0000000..b9b1ab8
--- /dev/null
@@ -0,0 +1,41 @@
+---\r
+- hosts: all\r
+  tasks:\r
+  - name: create a temporary file for additional data\r
+    file: \r
+      path: /tmp/tmp-{{Id}}\r
+      state: touch\r
+\r
+  - name: prepare additional data\r
+    shell: echo {{additionalData}} > /tmp/tmp-{{Id}}\r
+\r
+  - name: execute post-check operation\r
+    shell: ./swm/upgrade-post-check {{pnfId}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} /tmp/tmp-{{Id}}\r
+    ignore_errors: yes\r
+    register: postcheck_result\r
+\r
+  - name: write output to file\r
+    local_action: copy content="{{postcheck_result.stdout}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
+    when: postcheck_result.stdout != ""\r
+\r
+  - name: remove the temporary file\r
+    file:\r
+      path: /tmp/tmp-{{Id}}\r
+      state: absent\r
+\r
+  - name: build error message\r
+    set_fact:\r
+      err_msg:\r
+        "reason": "{{postcheck_result.stderr}}"\r
+        "result": "Failure"\r
+    when: postcheck_result is failed and postcheck_result.stdout == "" and postcheck_result.stderr != ""\r
+\r
+  - name: write error message to file\r
+    local_action: copy content="{{err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
+    when: postcheck_result is failed and postcheck_result.stdout == "" and postcheck_result.stderr != ""\r
+\r
+  - name: use result of post-check as the result of Playbook\r
+    fail:\r
+      msg: "{{postcheck_result.stderr}}"\r
+    when: postcheck_result is failed\r
+\r