Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #212 from eslutsky/he_deploy_enrich_failure_message
Browse files Browse the repository at this point in the history
Create more detailed log when deployment fails to add host to the engine
  • Loading branch information
irosenzw committed Jun 13, 2019
2 parents 191ef46 + c2a5aae commit ac64405
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions tasks/bootstrap_local_vm/05_add_host.yml
Expand Up @@ -126,16 +126,47 @@
retries: 120
delay: 5
- debug: var=host_result_up_check
- name: Check host status
fail:
msg: >
The host has been set in non_operational status,
please check engine logs,
fix accordingly and re-deploy.
- name: Handle deployment failure
block:
- set_fact: host_id={{ host_result_up_check.ansible_facts.ovirt_hosts[0].id }}
- name: Collect error events from the Engine
ovirt_event_facts:
auth: "{{ ovirt_auth }}"
search: "severity>=error"
register: error_events

- name: Generate the error message from the engine events
set_fact:
error_description: >-
{% for event in error_events.ansible_facts.ovirt_events | groupby('code') %}
{% if event[1][0].host.id == host_id %}
code {{ event[0] }}: {{ event[1][0].description }},
{% endif %}
{% endfor %}
ignore_errors: true

- name: Fail with error description
fail:
msg: >-
The host has been set in non_operational status,
deployment errors: {{ error_description }}
fix accordingly and re-deploy.
when: error_description is defined

- name: Fail with generic error
fail:
msg: >-
The host has been set in non_operational status,
please check engine logs,
more info can be found in the engine logs,
fix accordingly and re-deploy.
when: error_description is not defined

when: >-
host_result_up_check is succeeded and
host_result_up_check.ansible_facts.ovirt_hosts|length >= 1 and
host_result_up_check.ansible_facts.ovirt_hosts[0].status == 'non_operational'
- name: Remove host-deploy configuration file
file:
state: absent
Expand Down

0 comments on commit ac64405

Please sign in to comment.