# Copyright 2022 Google LLC
#
# 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: Wait for startup script to complete
  become: true
  wait_for:
    path: /var/log/messages
    search_regex: '.*{{ login_node }}.*startup-script exit status ([0-9]+)'
    timeout: 7200
    state: present
  register: startup_status
- name: Fail if startup script exited with a non-zero return code
  fail:
    msg: There was a failure in the startup script
  when: startup_status['match_groups'][0] != "0"
- name: Ensure spack is installed
  command: spack --version
- name: Ensure gromacs is installed
  shell: spack load gromacs
- name: Test gromacs is available on compute nodes
  shell: |
    spack load gromacs
    srun -N 1 gmx_mpi -version
    sleep 120

# Copyright 2022 Google LLC
#
# 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: Wait for startup script to complete
  become: true
  wait_for:
    path: /var/log/messages
    search_regex: '.*{{ login_node }}.*startup-script exit status ([0-9]+)'
    timeout: 7200
    state: present
  register: startup_status
- name: Fail if startup script exited with a non-zero return code
  fail:
    msg: There was a failure in the startup script
  when: startup_status['match_groups'][0] != "0"
- name: Ensure spack is installed
  command: spack --version
  changed_when: False
- name: Test gromacs is available on compute nodes
  shell: |
    spack load gromacs
    srun -N 1 gmx_mpi -version
    sleep 120
  register: srun_gromacs
  changed_when: srun_gromacs.rc == 0

Fix ansible-lint errors in spack test
Fix ansible-lint errors in spack test
