---\r
- hosts: all\r
tasks:\r
+\r
+ - name: parameter neIdentifier\r
+ set_fact:\r
+ ne_identifier: "{{neIdentifier}}"\r
+ when: neIdentifier is defined\r
+\r
+ - name: compatible with parameter pnfName\r
+ set_fact:\r
+ ne_identifier: "{{pnfName}}"\r
+ when: neIdentifier is not defined and pnfName is defined\r
+\r
- name: create a temporary file for additional data\r
- file: \r
- path: /tmp/tmp-{{Id}}\r
- state: touch\r
- become: false\r
+ tempfile: \r
+ state: file\r
+ register: additional_data_file\r
\r
- name: prepare additional data\r
- shell: echo {{additionalData}} > /tmp/tmp-{{Id}}\r
- become: false\r
+ copy:\r
+ content: "{{additionalData}}"\r
+ dest: "{{additional_data_file.path}}"\r
\r
- name: execute pre-check operation\r
- shell: ./swm/upgrade-pre-check {{pnfId}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} /tmp/tmp-{{Id}}\r
+ shell: ./swm/upgrade-pre-check {{ne_identifier}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} {{additional_data_file.path}}\r
ignore_errors: yes\r
register: precheck_result\r
\r
\r
- name: remove the temporary file\r
file:\r
- path: /tmp/tmp-{{Id}}\r
- state: absent\r
- become: false\r
+ path: "{{additional_data_file.path}}"\r
+ state: absent\r
+ when: additional_data_file.path is defined\r
+\r
+ - name: build error message\r
+ set_fact:\r
+ err_msg:\r
+ "reason": "{{precheck_result.stderr}}"\r
+ "result": "Failure"\r
+ when: precheck_result is failed and precheck_result.stdout == "" and precheck_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: precheck_result is failed and precheck_result.stdout == "" and precheck_result.stderr != ""\r
\r
- name: use result of pre-check as the result of Playbook\r
fail:\r