# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- name: Include variable file idrac_vars.yml
  include_vars: "{{ idrac_input_filename }}"
  run_once: true

- name: Assert firmware_update_required value
  assert:
    that:
      - firmware_update_required == true or firmware_update_required == false
    success_msg: "{{ firmware_update_success_msg }}"
    fail_msg: "{{ firmware_update_fail_msg }}"

- name: Read poweredge_model file
  command: cat {{ role_path }}/files/poweredge_models.txt
  failed_when: false
  register: poweredge_models_file_output
  changed_when: false

- name: Assert poweredge_model value
  assert:
    that:
      - item | length > 1
      - item in poweredge_models_file_output.stdout
    success_msg: "{{ poweredge_model_success_msg }}"
    fail_msg: "{{ poweredge_model_fail_msg }}"
  when: firmware_update_required
  with_items: "{{ poweredge_model.split(',') | map('trim') }}"
