aboutsummaryrefslogtreecommitdiffstats
path: root/installation
diff options
context:
space:
mode:
authorEnbo Wang <wangenbo@huawei.com>2019-05-10 10:04:18 +0000
committerEnbo Wang <wangenbo@huawei.com>2019-05-10 10:12:25 +0000
commit52f453cca65d3276ab860843ee34369a2d54dbb9 (patch)
treefee375242915a491eee9b73fa6e361c4721b79a4 /installation
parentca25565eac520f7ba65008a03323bb236d4de28f (diff)
Fix missing payload for DGs and Playbooks of SW upgrade
Change-Id: I89a118ef1e05c76800d6c2fa640dc3dcf2d78fca Issue-ID: SDNC-733 Signed-off-by: Enbo Wang <wangenbo@huawei.com> Former-commit-id: 7debdafa5ab5750a9953a1324a2fdb997fec1a54
Diffstat (limited to 'installation')
-rw-r--r--installation/ansible-server/src/main/Playbooks/ansible_huawei_postcheck@0.01.yml22
-rw-r--r--installation/ansible-server/src/main/Playbooks/ansible_huawei_precheck@0.01.yml22
-rw-r--r--installation/ansible-server/src/main/Playbooks/ansible_huawei_rollback@0.00.yml11
-rw-r--r--installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml63
4 files changed, 104 insertions, 14 deletions
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..b9b1ab81 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
@@ -3,13 +3,11 @@
tasks:
- name: create a temporary file for additional data
file:
- path: /tmp/tmp-{{Id}}
- state: touch
- become: false
+ path: /tmp/tmp-{{Id}}
+ state: touch
- name: prepare additional data
shell: echo {{additionalData}} > /tmp/tmp-{{Id}}
- become: false
- name: execute post-check operation
shell: ./swm/upgrade-post-check {{pnfId}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} /tmp/tmp-{{Id}}
@@ -22,9 +20,19 @@
- name: remove the temporary file
file:
- path: /tmp/tmp-{{Id}}
- state: absent
- become: false
+ path: /tmp/tmp-{{Id}}
+ state: absent
+
+ - 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:
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
index 668ed7d0..dcb6f6a0 100644
--- 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
@@ -3,13 +3,11 @@
tasks:
- name: create a temporary file for additional data
file:
- path: /tmp/tmp-{{Id}}
- state: touch
- become: false
+ path: /tmp/tmp-{{Id}}
+ state: touch
- name: prepare additional data
shell: echo {{additionalData}} > /tmp/tmp-{{Id}}
- become: false
- name: execute pre-check operation
shell: ./swm/upgrade-pre-check {{pnfId}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} /tmp/tmp-{{Id}}
@@ -22,9 +20,19 @@
- name: remove the temporary file
file:
- path: /tmp/tmp-{{Id}}
- state: absent
- become: false
+ path: /tmp/tmp-{{Id}}
+ state: absent
+
+ - name: build error message
+ set_fact:
+ err_msg:
+ "reason": "{{precheck_result.stderr}}"
+ "result": "Failure"
+ when: precheck_result is failed and precheck_result.stdout == "" and precheck_result.stderr != ""
+
+ - name: write error message to file
+ local_action: copy content="{{err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: precheck_result is failed and precheck_result.stdout == "" and precheck_result.stderr != ""
- name: use result of pre-check as the result of Playbook
fail:
diff --git a/installation/ansible-server/src/main/Playbooks/ansible_huawei_rollback@0.00.yml b/installation/ansible-server/src/main/Playbooks/ansible_huawei_rollback@0.00.yml
index fa164c9c..8d8982af 100644
--- a/installation/ansible-server/src/main/Playbooks/ansible_huawei_rollback@0.00.yml
+++ b/installation/ansible-server/src/main/Playbooks/ansible_huawei_rollback@0.00.yml
@@ -11,6 +11,17 @@
local_action: copy content="{{fallback_result.stdout}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
when: fallback_result.stdout != ""
+ - name: build error message
+ set_fact:
+ err_msg:
+ "reason": "{{fallback_result.stderr}}"
+ "result": "Failure"
+ when: fallback_result is failed and fallback_result.stdout == "" and fallback_result.stderr != ""
+
+ - name: write error message to file
+ local_action: copy content="{{err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: fallback_result is failed and fallback_result.stdout == "" and fallback_result.stderr != ""
+
- name: use result of swFallback as the result of Playbook
fail:
msg: "{{fallback_result.stderr}}"
diff --git a/installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml b/installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml
index 4ebe69f0..c4b76b0f 100644
--- a/installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml
+++ b/installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml
@@ -38,8 +38,25 @@
- name: execute downloadNESw operation
shell: ./swm/downloadNESw --swToBeDownloaded {{sw_to_be_downloaded}} --neIdentifier {{ne_identifier}}
+ ignore_errors: yes
register: download_result
+ - name: build error message for downloadNESw
+ set_fact:
+ download_err_msg:
+ "reason": "downloadNESw failure"
+ "result": "Failure"
+ when: download_result is failed
+
+ - name: write error message to file for downloadNESw
+ local_action: copy content="{{download_err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: download_result is failed
+
+ - name: use result of downloadNESw as the result of Playbook
+ fail:
+ msg: "{{download_err_msg}}"
+ when: download_result is failed
+
- name: parse response of downloadNESw
set_fact:
download_response: "{{ download_result.stdout | from_json }}"
@@ -67,11 +84,13 @@
- name: execute installNESw operation
shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}
+ ignore_errors: yes
register: install_result
with_items: "{{ downloaded_ne_sw_info | default([]) }}"
- name: execute installNESw operation using new parameter
shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}
+ ignore_errors: yes
register: install_result_new
with_items: "{{ sw_to_be_installed | default([]) }}"
@@ -80,6 +99,22 @@
install_result: "{{ install_result_new }}"
when: swToBeInstalled is defined
+ - name: build error message for installNESw
+ set_fact:
+ install_err_msg:
+ "reason": "installNESw failure"
+ "result": "Failure"
+ when: install_result is failed
+
+ - name: write error message to file for installNESw
+ local_action: copy content="{{install_err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: install_result is failed
+
+ - name: use result of installNESw as the result of Playbook
+ fail:
+ msg: "{{install_err_msg}}"
+ when: install_result is failed
+
- name: set install results list
set_fact:
install_results_list: "{{ install_result.results }}"
@@ -112,11 +147,13 @@
- name: execute activateNESw operation
shell: ./swm/activateNESw --swVersionToBeActivated {{item}} --neIdentifier {{ne_identifier}}
+ ignore_errors: yes
register: activate_result
with_items: "{{ installed_ne_sw_info | default([]) }}"
- name: execute activateNESw operation using new parameter
shell: ./swm/activateNESw --swVersionToBeActivated {{sw_version_to_be_activated}} --neIdentifier {{ne_identifier}}
+ ignore_errors: yes
register: activate_result_new
when: swVersionToBeActivated is defined
@@ -125,3 +162,29 @@
activate_result: "{{ activate_result_new }}"
when: swVersionToBeActivated is defined
+ - name: build error message for activateNESw
+ set_fact:
+ activate_err_msg:
+ "reason": "activateNESw failure"
+ "result": "Failure"
+ when: activate_result is failed
+
+ - name: write error message to file for activateNESw
+ local_action: copy content="{{activate_err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: activate_result is failed
+
+ - name: use result of activateNESw as the result of Playbook
+ fail:
+ msg: "{{activate_err_msg}}"
+ when: activate_result is failed
+
+ - name: build success message for activateNESw
+ set_fact:
+ activate_success_msg:
+ "result": "Success"
+ when: activate_result is not failed
+
+ - name: write success message to file for activateNESw
+ local_action: copy content="{{activate_success_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: activate_result is not failed
+