# 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: Set system_lockdown in lowercase
  set_fact:
    system_lockdown: "{{ system_lockdown | lower }}"

- name: Assert system_lockdown value
  assert:
    that:
      - system_lockdown | length > 1
      - system_lockdown == "enabled" or system_lockdown == "disabled"
    success_msg: "{{ system_lockdown_success_msg }}"
    fail_msg: "{{ system_lockdown_fail_msg }}"
    
- name: Enable system lockdown
  dellemc.openmanage.dellemc_system_lockdown_mode:
    idrac_ip: "{{ inventory_hostname }}"
    idrac_user: "{{ idrac_username }}"
    idrac_password: "{{ idrac_password }}"
    share_name: "{{ playbook_dir }}"
    lockdown_mode: "Enabled"
  when: system_lockdown == "enabled"

- name: Disable system lockdown
  dellemc.openmanage.dellemc_system_lockdown_mode:
    idrac_ip: "{{ inventory_hostname }}"
    idrac_user: "{{ idrac_username }}"
    idrac_password: "{{ idrac_password }}"
    share_name: "{{ playbook_dir }}"
    lockdown_mode: "Disabled"
  when: system_lockdown == "disabled"