---
- hosts: undercloud
  vars:
    metadata:
      name: Stack Health Check
      description: >
        Check if all stack resources are in a *_COMPLETE state before starting
        an upgrade.
      groups:
        - pre-upgrade
        - post-upgrade
  tasks:
  - name: Check stack resource statuses
    assert:
      that:
        - "'_COMPLETE' in item.resource_status"
      msg: "Health check failed for resource {{ item.resource_name }} with status: {{ item.resource_status }}"
    with_items: "{{ lookup('stack_resources', wantlist=True) }}"
