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