Skip to content

Commit

Permalink
Merge pull request #41 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Dec 5, 2023
2 parents b9de3d7 + 0be3e42 commit 44e9ad5
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 30 deletions.
45 changes: 20 additions & 25 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,29 @@ jobs:
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
distro:
- centos8
- rockylinux9
- ubuntu2004
- ubuntu2204

steps:
- name: checkout
- name: Check out the codebase.
uses: actions/checkout@v2

- name: Install python
run: sudo apt update && sudo apt install -y python3 python3-pip python3-setuptools
- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install Ansible
run: sudo pip3 install ansible
- name: Install test dependencies.
run: pip3 install ansible molecule-plugins[docker] docker

- name: Create ansible.cfg with correct roles_path
run: sudo printf '[defaults]\nhost_key_checking = False\nroles_path=../' > ansible.cfg

- name: Install role dependencies
run: sudo ansible-galaxy install geerlingguy.ntp grycap.munge grycap.ssh -f

- name: Basic role syntax check
run: sudo ansible-playbook tests/test.yml -i tests/inventory --syntax-check

- name: Basic role check in front
run: sudo ansible-playbook tests/test.yml -i tests/inventory

- name: Idempotence role check in front
run: sudo ansible-playbook tests/test.yml -i tests/inventory

- name: Basic role check in wn
run: sudo ansible-playbook tests/test.yml -i tests/inventory -e slurm_type_of_node=wn

- name: Idempotence role check in wn
run: sudo ansible-playbook tests/test.yml -i tests/inventory -e slurm_type_of_node=wn
- name: Run Molecule tests.
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
41 changes: 41 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
- name: Converge
hosts: all
become: true

tasks:

- name: "Include grycap.slurm"
include_role:
name: "ansible-role-slurm"
vars:
slurm_wn_cpus: 2
slurm_wn_mem: 1048576
slurm_wn_gres: "gpu:tesla:2"
slurm_server_name: instance
slurm_wn_ips: ["127.0.0.1"]
slurm_vnode_prefix: vnode-
max_number_of_nodes: 1
drmaa_lib_install: true
drmaa_lib_version: 1.1.4
slurm_version: 21.08.8

- name: "Include grycap.slurm"
include_role:
name: "ansible-role-slurm"
vars:
slurm_type_of_node: wn
slurm_wn_cpus: 2
slurm_wn_mem: 1048576
slurm_wn_gres: "gpu:tesla:2"
slurm_server_name: instance
slurm_wn_ips: ["127.0.0.1"]
slurm_vnode_prefix: vnode-
max_number_of_nodes: 1
drmaa_lib_install: true
drmaa_lib_version: 1.1.4
slurm_version: 21.08.8

- name: Test
command: scontrol show nodes
changed_when: False
30 changes: 30 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
scenario:
name: default
test_sequence:
- dependency
- destroy
- create
- prepare
- converge
# - idempotence
- verify
dependency:
name: galaxy
driver:
name: docker
verifier:
name: ansible
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
10 changes: 10 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Prepare
hosts: all
gather_facts: true

pre_tasks:
- name: Update cache on Debian
apt:
update_cache: yes
when: ansible_os_family == "Debian"
3 changes: 3 additions & 0 deletions molecule/default/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: geerlingguy.ntp
- name: grycap.ssh
- name: grycap.munge
16 changes: 16 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Verify
hosts: all
become: true

tasks:

- name: Test
command: scontrol show nodes
register: nodes

- name: Check service running
fail:
msg: "Error getting node info"
when:
- "'NodeName=vnode-1' not in nodes.stdout"
4 changes: 2 additions & 2 deletions tasks/drmaa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- block:

- name: Install GCC
package: name=gcc state=present
package: name=gcc,make state=present

- set_fact:
INSTALL_PATH: /opt
Expand Down Expand Up @@ -44,7 +44,7 @@

- name: Configure lib
command:
cmd: ./configure --with-slurm-inc={{ SLURM_INC }} --with-slurm-lib={{ SLURM_LIB }} --sysconfdir=/etc
cmd: ./configure --disable-dependency-tracking --with-slurm-inc={{ SLURM_INC }} --with-slurm-lib={{ SLURM_LIB }} --sysconfdir=/etc
creates: "{{ INSTALL_PATH }}/{{ FILENAME }}/Makefile"
chdir: "{{ INSTALL_PATH }}/{{ FILENAME }}"

Expand Down
20 changes: 17 additions & 3 deletions tasks/wn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,29 @@
delegate_to: "{{slurm_server_name}}"
when: TEST is not defined

- name: Copy slurm.conf to the master
fetch: src="{{ SLURM_CONF_DIR }}/slurm.conf" dest="/tmp/slurm.conf" flat=yes
delegate_to: "{{slurm_server_name}}"

- name: copy slurm.conf file from the frontend
copy: src={{ SLURM_CONF_DIR }}/slurm.conf dest={{ SLURM_CONF_DIR }}/slurm.conf force=yes
copy: src=/tmp/slurm.conf dest={{ SLURM_CONF_DIR }}/slurm.conf force=yes

- name: Copy cgroup.conf to the master
fetch: src="{{ SLURM_CONF_DIR }}/cgroup.conf" dest="/tmp/cgroup.conf" flat=yes
when: "slurm_version is version('22.0.0', '>=')"
delegate_to: "{{slurm_server_name}}"

- name: copy cgroup.conf file from the frontend
copy: src={{ SLURM_CONF_DIR }}/cgroup.conf dest={{ SLURM_CONF_DIR }}/cgroup.conf force=yes
copy: src=/tmp/cgroup.conf dest={{ SLURM_CONF_DIR }}/cgroup.conf force=yes
when: "slurm_version is version('22.0.0', '>=')"

- name: Copy gres.conf to the master
fetch: src="{{ SLURM_CONF_DIR }}/gres.conf" dest="/tmp/gres.conf" flat=yes
when: slurm_wn_gres != ""
delegate_to: "{{slurm_server_name}}"

- name: copy gres.conf file from the frontend
copy: src={{ SLURM_CONF_DIR }}/gres.conf dest={{ SLURM_CONF_DIR }}/gres.conf force=yes
copy: src=/tmp/gres.conf dest={{ SLURM_CONF_DIR }}/gres.conf force=yes
when: slurm_wn_gres != ""

- name: Wait 5 secs to enable slurm to start
Expand Down

0 comments on commit 44e9ad5

Please sign in to comment.