#  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: Refresh ssh keys
  command: ssh-keygen -R {{ groups['powervault_me4'][0] }}
  changed_when: false
  tags: install
  failed_when: false

- name: Validate authentication of username and password
  command: ping -c1 {{ groups['powervault_me4'][0] }}
  register: validate_login
  changed_when: false
  failed_when: false

- name: Scan for getting the volume
  command: rescan-scsi-bus.sh --forcerescan
  changed_when: false
  register: volume_pv
  tags: install

- name: Assert if volume created or not
  assert:
    that:
      - "' Model: ME4' in volume_pv.stdout"
    success_msg: "Volume is created"
    fail_msg: "Volume is not created properly."
  tags: install
