From 79f56f7aa36e65aab26e80b793a59388f71b3c8a Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Mon, 4 Dec 2023 14:01:29 +0100 Subject: [PATCH 1/6] update meta --- meta/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meta/main.yml b/meta/main.yml index 6067ee0..78290a5 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,4 +1,6 @@ galaxy_info: + role_name: slurm + namespace: grycap author: alpegon3@upv.es description: Install SLURM cluster company: GRyCAP From e56e21084aad75fe7d8370aaf430e9cac62270b5 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 5 Dec 2023 13:33:18 +0100 Subject: [PATCH 2/6] Improve tests --- .github/workflows/main.yaml | 45 ++++++++++++++----------------- molecule/default/converge.yml | 41 ++++++++++++++++++++++++++++ molecule/default/molecule.yml | 28 +++++++++++++++++++ molecule/default/requirements.yml | 2 ++ molecule/default/verify.yml | 16 +++++++++++ tasks/drmaa.yml | 4 +-- tasks/wn.yaml | 17 +++++++++--- 7 files changed, 123 insertions(+), 30 deletions(-) create mode 100644 molecule/default/converge.yml create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/requirements.yml create mode 100644 molecule/default/verify.yml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6494aec..ff5ec30 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -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 - - - 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 \ No newline at end of file + - name: Run Molecule tests. + run: molecule test --all + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + MOLECULE_DISTRO: ${{ matrix.distro }} diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..788cb94 --- /dev/null +++ b/molecule/default/converge.yml @@ -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 diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..427db58 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,28 @@ +--- +scenario: + name: default + test_sequence: + - destroy + - create + - converge + # - idempotence + - verify +dependency: + name: galaxy +driver: + name: docker +verifier: + name: ansible +platforms: + - name: instance + image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-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} diff --git a/molecule/default/requirements.yml b/molecule/default/requirements.yml new file mode 100644 index 0000000..e418c37 --- /dev/null +++ b/molecule/default/requirements.yml @@ -0,0 +1,2 @@ +- name: grycap.munge +- name: grycap.ssh diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..853a70c --- /dev/null +++ b/molecule/default/verify.yml @@ -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" diff --git a/tasks/drmaa.yml b/tasks/drmaa.yml index 9336584..41ec9bb 100644 --- a/tasks/drmaa.yml +++ b/tasks/drmaa.yml @@ -7,7 +7,7 @@ - block: - name: Install GCC - package: name=gcc state=present + package: name=gcc,make state=present - set_fact: INSTALL_PATH: /opt @@ -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 }}" diff --git a/tasks/wn.yaml b/tasks/wn.yaml index bd46162..3de0820 100644 --- a/tasks/wn.yaml +++ b/tasks/wn.yaml @@ -9,15 +9,26 @@ 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 + - 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', '>=')" - 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 != "" + - 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 From 3cec44c37248eb52f69559607d46f0df56b3dcad Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 5 Dec 2023 13:40:17 +0100 Subject: [PATCH 3/6] Improve tests --- molecule/default/requirements.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/molecule/default/requirements.yml b/molecule/default/requirements.yml index e418c37..df54796 100644 --- a/molecule/default/requirements.yml +++ b/molecule/default/requirements.yml @@ -1,2 +1,3 @@ - name: grycap.munge - name: grycap.ssh +- name: geerlingguy.ntp From 016ee3b071a43cbdd692992db0c546fc41060efb Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 5 Dec 2023 13:53:11 +0100 Subject: [PATCH 4/6] Improve tests --- molecule/default/molecule.yml | 1 + molecule/default/requirements.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 427db58..28be66e 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -2,6 +2,7 @@ scenario: name: default test_sequence: + - dependency - destroy - create - converge diff --git a/molecule/default/requirements.yml b/molecule/default/requirements.yml index df54796..c055714 100644 --- a/molecule/default/requirements.yml +++ b/molecule/default/requirements.yml @@ -1,3 +1,3 @@ -- name: grycap.munge -- name: grycap.ssh - name: geerlingguy.ntp +- name: grycap.ssh +- name: grycap.munge From 29cda145377142a33971efe6064329b96ab24002 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 5 Dec 2023 15:49:48 +0100 Subject: [PATCH 5/6] Fix test --- molecule/default/molecule.yml | 3 ++- molecule/default/prepare.yml | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 molecule/default/prepare.yml diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 28be66e..8a8b467 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -5,6 +5,7 @@ scenario: - dependency - destroy - create + - prepare - converge # - idempotence - verify @@ -16,7 +17,7 @@ verifier: name: ansible platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" command: ${MOLECULE_DOCKER_COMMAND:-""} volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml new file mode 100644 index 0000000..d96742a --- /dev/null +++ b/molecule/default/prepare.yml @@ -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" From 0be3e4277c79aac9f9f28d2adfd5ff589d3afbe9 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 5 Dec 2023 16:20:45 +0100 Subject: [PATCH 6/6] Fix fetch --- tasks/wn.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/wn.yaml b/tasks/wn.yaml index 3de0820..389fbb3 100644 --- a/tasks/wn.yaml +++ b/tasks/wn.yaml @@ -11,6 +11,7 @@ - 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=/tmp/slurm.conf dest={{ SLURM_CONF_DIR }}/slurm.conf force=yes @@ -18,6 +19,7 @@ - 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=/tmp/cgroup.conf dest={{ SLURM_CONF_DIR }}/cgroup.conf force=yes @@ -26,6 +28,7 @@ - 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=/tmp/gres.conf dest={{ SLURM_CONF_DIR }}/gres.conf force=yes