Browse Source

Merge pull request #763 from DeepikaKrishnaiah/devel

Install slurm restd on manager node
Sujit Jadhav 3 years ago
parent
commit
4ce3837e6b

+ 9 - 2
omnia.yml

@@ -1,4 +1,4 @@
-# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+# Copyright 2022 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.
@@ -214,6 +214,13 @@
     - slurm_exporter
   tags: slurm
 
+- name: Install slurm restd
+  hosts: manager
+  gather_facts: false
+  roles:
+    - slurm_restd
+  tags: slurm
+
 - name: Passwordless SSH between manager and compute nodes
   include: control_plane/tools/passwordless_ssh.yml
-  when: hostvars['127.0.0.1']['control_plane_status']
+  when: hostvars['127.0.0.1']['control_plane_status']

+ 3 - 1
roles/slurm_manager/tasks/main.yml

@@ -1,4 +1,4 @@
-#  Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
+#  Copyright 2022 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.
@@ -100,9 +100,11 @@
     - "{{ tcp_port2 }}"
     - "{{ tcp_port3 }}"
     - "{{ tcp_port4 }}"
+    - "{{ tcp_port5 }}"
     - "{{ udp_port3 }}"
     - "{{ udp_port1 }}"
     - "{{ udp_port2 }}"
+    - "{{ udp_port4 }}"
   when: "'manager' in group_names"
   tags: firewalld
 

+ 3 - 1
roles/slurm_manager/vars/main.yml

@@ -1,4 +1,4 @@
-#  Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
+#  Copyright 2022 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.
@@ -54,9 +54,11 @@ tcp_port1: "6817/tcp"
 tcp_port2: "6818/tcp"
 tcp_port3: "6819/tcp"
 tcp_port4: "60001-63000/tcp"
+tcp_port5: "6820/tcp"
 udp_port1: "6817/udp"
 udp_port2: "6818/udp"
 udp_port3: "6819/udp"
+udp_port4: "6820/udp"
 family: "ipv4"
 db_user: "slurm"
 db_host: "localhost"

+ 10 - 0
roles/slurm_restd/files/slurm-restd-custom.service

@@ -0,0 +1,10 @@
+[Unit]
+Description = Start slurm restd
+
+[Service]
+ExecStart = slurmrestd -a rest_auth/jwt -s openapi/v0.0.36 "0.0.0.0:6820"
+Restart = always
+RestartSec = 15
+
+[Install]
+WantedBy = multi-user.target

+ 78 - 0
roles/slurm_restd/tasks/generate_token.yml

@@ -0,0 +1,78 @@
+# Copyright 2022 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: Generate key
+  command: dd if=/dev/random of="{{ token_dir }}" bs=32 count=1
+  changed_when: false
+
+- name: Copy the key to /etc/slurm
+  copy:
+    src: "{{ token_dir }}"
+    dest: "{{ slurm_dir }}"
+    owner: slurm
+    group: slurm
+    mode: "{{ token_mode }}"
+    remote_src: yes
+
+- name: Add authentication alt type entry in slurm.conf
+  lineinfile:
+    path: "{{ slurm_conf_path }}"
+    insertafter: 'AuthType=auth/munge\n'
+    line: 'AuthAltTypes=auth/jwt'
+
+- name: Add auth alt parameter entry in slurm.conf
+  lineinfile:
+    path: "{{ slurm_conf_path }}"
+    insertafter: 'AuthAltTypes=auth/jwt\n'
+    line: 'AuthAltParameters=jwt_key=/etc/slurm/jwt_hs256.key'
+
+- name: Restart slurmctld
+  systemd:
+    name: slurmctld
+    state: restarted
+    daemon_reload: yes
+    enabled: yes
+
+- name: Create systemd unit file
+  copy:
+    src: "{{ role_path }}/files/slurm-restd-custom.service"
+    dest: "{{ systemd_path_dest }}"
+    remote_src: no
+    mode: "{{ fil_mode }}"
+
+- name: Fetch hostname
+  command: hostname
+  register: current_hostname
+  changed_when: false
+
+- name: Set fact for server hostname
+  set_fact:
+    manager_hostname: "{{ current_hostname.stdout }}"
+
+- name: Update the port in service file
+  replace:
+    path: "{{ systemd_path_dest }}/slurm-restd-custom.service"
+    regexp: "0.0.0.0:6820"
+    replace: "{{ manager_hostname }}:{{ slurm_restd_port }}"
+
+- name: Add random token
+  shell: set -o pipefail && export SLURM_JWT=nvisjvopaekgvgoawkgvpao84r93fjmdkvmdkvm
+  changed_when: false
+
+- name: Start services
+  systemd:
+    name: slurm-restd-custom.service
+    state: restarted
+    enabled: yes

+ 46 - 0
roles/slurm_restd/tasks/install_jansson.yml

@@ -0,0 +1,46 @@
+# Copyright 2022 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: Install packages for slurm restd
+  package:
+    name: "{{ slurm_restd_packages }}"
+    state: present
+  tags: install
+
+- name: Download and untar jansson package
+  unarchive:
+    src: "{{ jansson_src_url }}"
+    dest: "{{ jansson_download_dir }}"
+    remote_src: yes
+
+- name: Go to jansson directory
+  command: cd "{{ jansson_dir_path }}"
+  changed_when: false
+
+- name: Execute autoreconf
+  shell:  set -o pipefail && cd "{{ jansson_dir_path }}" && autoreconf -i
+  changed_when: false
+
+- name: Configure jansson
+  shell:  set -o pipefail && cd "{{ jansson_dir_path }}" && ./configure
+  changed_when: false
+
+- name: Execute make
+  shell:  set -o pipefail && cd "{{ jansson_dir_path }}" && make
+  changed_when: false
+
+- name: Execute make install
+  shell:  set -o pipefail && cd "{{ jansson_dir_path }}" && make install
+  changed_when: false

+ 52 - 0
roles/slurm_restd/tasks/install_libjwt.yml

@@ -0,0 +1,52 @@
+# Copyright 2022 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: Git clone libjwt
+  git:
+    repo: "{{ libjwt_repo }}"
+    dest: "{{ libjwt_dir }}"
+    clone: yes
+    depth: 1
+    #single_branch: yes
+    version: v1.12.0
+  tags: install
+
+- name: Execute autoreconf
+  shell:  set -o pipefail && cd "{{ libjwt_dir }}" && autoreconf --force --install
+  changed_when: false
+  environment:
+    PKG_CONFIG_PATH: "{{ jansson_path }}"
+    PATH: "{{ ansible_env.PATH }}:{{ jansson_path }}"
+
+- name: Configure libjwt
+  shell:  set -o pipefail && cd "{{ libjwt_dir }}" && ./configure --prefix=/usr/local
+  changed_when: false
+  environment:
+    PKG_CONFIG_PATH: "{{ jansson_path }}"
+    PATH: "{{ ansible_env.PATH }}:{{ jansson_path }}"
+
+- name: Execute make
+  shell:  set -o pipefail && cd "{{ libjwt_dir }}" && make -j
+  changed_when: false
+  environment:
+    PKG_CONFIG_PATH: "{{ jansson_path }}"
+    PATH: "{{ ansible_env.PATH }}:{{ jansson_path }}"
+
+- name: Execute make install
+  shell:  set -o pipefail && cd "{{ libjwt_dir }}" && make install
+  changed_when: false
+  environment:
+    PKG_CONFIG_PATH: "{{ jansson_path }}"
+    PATH: "{{ ansible_env.PATH }}:{{ jansson_path }}"

+ 23 - 0
roles/slurm_restd/tasks/main.yml

@@ -0,0 +1,23 @@
+# Copyright 2022 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: Install jansson
+  include_tasks: install_jansson.yml
+
+- name: Install libjwt
+  include_tasks: install_libjwt.yml
+
+- name: Generate Token
+  include_tasks: generate_token.yml

+ 40 - 0
roles/slurm_restd/vars/main.yml

@@ -0,0 +1,40 @@
+#  Copyright 2022 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.
+---
+
+# Usage: install_jansson.yml
+slurm_restd_packages:
+   - slurm-slurmrestd
+   - http-parser-devel
+   - json-c-devel
+   - libtool
+   - make
+
+fil_mode: "0755"
+jansson_download_dir: /var/lib/
+jansson_src_url: https://github.com/akheron/jansson/archive/refs/tags/v2.14.tar.gz
+jansson_path: /usr/local/lib/pkgconfig
+jansson_dir_path: /var/lib/jansson-2.14/
+
+# Usage: install_libjwt.yml
+libjwt_repo: https://github.com/benmcollins/libjwt.git
+libjwt_dir: /var/lib/libjwt
+
+# Usage: generate_token.yml
+token_dir: /var/spool/slurm/jwt_hs256.key
+slurm_dir: /etc/slurm/
+slurm_conf_path: /etc/slurm/slurm.conf
+token_mode: '0600'
+systemd_path_dest: "/etc/systemd/system/"
+slurm_restd_port: "6820"