X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=installation%2Fansible-server%2Fsrc%2Fmain%2FPlaybooks%2Fansible_huawei_postcheck%400.01.yml;h=cc867c145d53ec54497710d24e6aae03b7cfd1cf;hb=226baa784e543bef038cffe091f734d22b34a256;hp=ad4edf51a3098cefc8a00f2a2e2edfaa4d189eff;hpb=e5aea0d8f2ca5c50cf65a2bfad92d2522743fcbf;p=sdnc%2Foam.git diff --git a/installation/ansible-server/src/main/Playbooks/ansible_huawei_postcheck@0.01.yml b/installation/ansible-server/src/main/Playbooks/ansible_huawei_postcheck@0.01.yml index ad4edf51..cc867c14 100644 --- a/installation/ansible-server/src/main/Playbooks/ansible_huawei_postcheck@0.01.yml +++ b/installation/ansible-server/src/main/Playbooks/ansible_huawei_postcheck@0.01.yml @@ -1,18 +1,29 @@ --- - hosts: all tasks: + + - 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: create a temporary file for additional data - file: - path: /tmp/tmp-{{Id}} - state: touch - become: false + tempfile: + state: file + register: additional_data_file - name: prepare additional data - shell: echo {{additionalData}} > /tmp/tmp-{{Id}} - become: false + copy: + content: "{{additionalData}}" + dest: "{{additional_data_file.path}}" - name: execute post-check operation - shell: ./swm/upgrade-post-check {{pnfId}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} /tmp/tmp-{{Id}} + shell: ./swm/upgrade-post-check {{ne_identifier}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} {{additional_data_file.path}} ignore_errors: yes register: postcheck_result @@ -22,9 +33,20 @@ - name: remove the temporary file file: - path: /tmp/tmp-{{Id}} - state: absent - become: false + path: "{{additional_data_file.path}}" + state: absent + when: additional_data_file.path is defined + + - 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: