Add missing payload for DGs and Playbooks of LCM APIs
[sdnc/oam.git] / installation / ansible-server / src / main / Playbooks / ansible_huawei_precheck@0.01.yml
diff --git a/installation/ansible-server/src/main/Playbooks/ansible_huawei_precheck@0.01.yml b/installation/ansible-server/src/main/Playbooks/ansible_huawei_precheck@0.01.yml
new file mode 100644 (file)
index 0000000..668ed7d
--- /dev/null
@@ -0,0 +1,33 @@
+---\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
+    become: false\r
+\r
+  - name: prepare additional data\r
+    shell: echo {{additionalData}} > /tmp/tmp-{{Id}}\r
+    become: false\r
+\r
+  - name: execute pre-check operation\r
+    shell: ./swm/upgrade-pre-check {{pnfId}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} /tmp/tmp-{{Id}}\r
+    ignore_errors: yes\r
+    register: precheck_result\r
+\r
+  - name: write output to file\r
+    local_action: copy content="{{precheck_result.stdout}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
+    when: precheck_result.stdout != ""\r
+\r
+  - name: remove the temporary file\r
+    file:\r
+        path: /tmp/tmp-{{Id}}\r
+        state: absent\r
+    become: false\r
+\r
+  - name: use result of pre-check as the result of Playbook\r
+    fail:\r
+      msg: "{{precheck_result.stderr}}"\r
+    when: precheck_result is failed\r
+\r