Update DGs and Playbooks for PNF SW Upgrade
[sdnc/oam.git] / installation / ansible-server / src / main / Playbooks / ansible_huawei_precheck@0.01.yml
1 ---\r
2 - hosts: all\r
3   tasks:\r
4 \r
5   - name: parameter neIdentifier\r
6     set_fact:\r
7       ne_identifier: "{{neIdentifier}}"\r
8     when: neIdentifier is defined\r
9 \r
10   - name: compatible with parameter pnfName\r
11     set_fact:\r
12       ne_identifier: "{{pnfName}}"\r
13     when: neIdentifier is not defined and pnfName is defined\r
14 \r
15   - name: create a temporary file for additional data\r
16     tempfile: \r
17       state: file\r
18     register: additional_data_file\r
19 \r
20   - name: prepare additional data\r
21     copy:\r
22       content: "{{additionalData}}"\r
23       dest: "{{additional_data_file.path}}"\r
24 \r
25   - name: execute pre-check operation\r
26     shell: ./swm/upgrade-pre-check {{ne_identifier}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} {{additional_data_file.path}}\r
27     ignore_errors: yes\r
28     register: precheck_result\r
29 \r
30   - name: write output to file\r
31     local_action: copy content="{{precheck_result.stdout}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
32     when: precheck_result.stdout != ""\r
33 \r
34   - name: remove the temporary file\r
35     file:\r
36       path: "{{additional_data_file.path}}"\r
37       state: absent\r
38     when: additional_data_file.path is defined\r
39 \r
40   - name: build error message\r
41     set_fact:\r
42       err_msg:\r
43         "reason": "{{precheck_result.stderr}}"\r
44         "result": "Failure"\r
45     when: precheck_result is failed and precheck_result.stdout == "" and precheck_result.stderr != ""\r
46 \r
47   - name: write error message to file\r
48     local_action: copy content="{{err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
49     when: precheck_result is failed and precheck_result.stdout == "" and precheck_result.stderr != ""\r
50 \r
51   - name: use result of pre-check as the result of Playbook\r
52     fail:\r
53       msg: "{{precheck_result.stderr}}"\r
54     when: precheck_result is failed\r
55 \r