# 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: Install genisoimage package
  package:
    name: genisoimage
    state: present
  tags: install

- name: Install ansible-galaxy modules
  command: ansible-galaxy collection install {{ item }}
  changed_when: true
  with_items:
   - community.general
   - dellemc.openmanage

- name: Install omsdk using pip
  pip:
    name: omsdk
    state: present
  tags: install

- name: Check iso mount folder
  stat:
    path: "{{ iso_mount_path }}{{ isolinux_cfg_path }}"
  register: check_mount_iso
  tags: install

- name: Incorrect iso mount
  fail:
    msg: "{{ iso_mount_check_fail_msg }}"
  when: not check_mount_iso.stat.exists
  register: iso_mount_fail
  tags: install

- name: Copy management station ip to {{ management_station_ip_file }}
  lineinfile:
    path: "{{ role_path }}/../provision_idrac/files/{{ management_station_ip_file }}"
    line: "{{ mngmnt_network_ip }}"
    mode: "{{ file_permission }}"
    create: yes