---
- name: gather facts used by role
  setup:
    gather_subset: "!min,pkg_mgr"
  when: ansible_pkg_mgr is not defined

- name: Reinstall the undercloud to check idempotency
  shell: >
    set -o pipefail &&
    {{ working_dir }}/undercloud-install.sh 2>&1 {{ timestamper_cmd }} >
    {{ undercloud_reinstall_log }}
  when: undercloud_check_idempotency|bool
  tags:
    - undercloud-validate

- name: Create undercloud sanity check script
  template:
    src: "{{ undercloud_sanity_check_script }}"
    dest: "{{ working_dir }}/undercloud-sanity-check.sh"
    mode: 0755
  tags:
    - undercloud-scripts

- name: check undercloud sanity
  shell: >
    set -o pipefail &&
    {{ working_dir }}/undercloud-sanity-check.sh 2>&1 {{ timestamper_cmd }} >
    {{ undercloud_sanity_check_log }}
  when: undercloud_check_sanity|bool
  tags:
    - undercloud-validate
