Browse Source

Issue #762: Install slurm restd daemon

Signed-off-by: DeepikaKrishnaiah <deepika_k2@dell.com>
DeepikaKrishnaiah 3 years ago
parent
commit
9c153247ad

+ 0 - 1
control_plane/roles/control_plane_common/tasks/main.yml

@@ -15,7 +15,6 @@
 
 - name: Pre-requisite validation
   import_tasks: pre_requisite.yml
-  tags: init
 
 - name: Internet validation
   import_tasks: internet_validation.yml

+ 20 - 2
control_plane/roles/control_plane_common/tasks/pre_requisite.yml

@@ -13,29 +13,42 @@
 #  limitations under the License.
 ---
 
+- name: Validate skip tags
+  fail:
+    msg: "{{ invalid_skip_tag_msg }}"
+  tags: [ network-device, pxe, awx, network-ib, idrac, monitoring, security, firmware-repo, templates ]
+  when:
+    - '"init" in ansible_skip_tags'
+
 - name: Validate run tags
   fail:
-    msg: "{{ invalid_tag_msg }}"
-  when: '"init" not in ansible_run_tags'
+    msg: "{{ invalid_run_tag_msg }}"
+  when:
+    - '"init" not in ansible_run_tags'
+    - '"all" not in ansible_run_tags'
   tags: [ init, network-device, pxe, awx, network-ib, idrac, monitoring, security, firmware-repo, templates ]
 
 - name: Mount Path
   set_fact:
     mount_path: "{{ role_path + '/../../..'  }}"
+  tags: init
     
 - name: Collecting ansible python version
   shell:
     cmd: ansible --version | grep "python version" | cut -d ' ' -f 6
   register: ansible_python_version
   changed_when: false
+  tags: init
 
 - name: Saving management station os
   set_fact:
     mgmt_os: "{{ ansible_facts['distribution'] | lower }}"
+  tags: init
 
 - name: Verify the ansible and python versions installed
   fail:
     msg: "{{ ansible_python_version_status }}"
+  tags: init
   when:
     - ansible_python_version.stdout != python_version_leap
     - ansible_python_version.stdout != python_version_support
@@ -44,6 +57,7 @@
   stat:
     path: "{{ default_ansible_config_file_path }}"
   register: file_exists
+  tags: init
 
 - name: Set omnia.log file
   replace:
@@ -51,6 +65,7 @@
     regexp: '#log_path = /var/log/ansible.log'
     replace: 'log_path = /var/log/omnia.log'
   when: file_exists.stat.exists
+  tags: init
 
 - name: Check OS support
   assert:
@@ -61,6 +76,7 @@
     fail_msg: "{{ fail_os_status }}"
     success_msg: "{{ success_os_status }}"
   register: os_value
+  tags: init
 
 - block:
     - name: Fetch SElinux mode
@@ -80,6 +96,7 @@
         msg: "{{ selinux_status }}"
       when: '"SELinux status: enabled" in sestatus_current.stdout_lines'
       register: selinux_value
+  tags: init
   when:
     - ( mgmt_os == os_supported_centos ) and ( ansible_distribution_version >= os_supported_centos_version ) or
       ( mgmt_os == os_supported_rocky ) and ( ansible_distribution_version >= os_supported_rocky_version )
@@ -89,3 +106,4 @@
     name: firewalld
     state: started
     enabled: yes
+  tags: init

+ 2 - 1
control_plane/roles/control_plane_common/vars/main.yml

@@ -71,7 +71,8 @@ selinux_status: "SElinux is not disabled. Disable it in /etc/sysconfig/selinux a
 ansible_python_version_status: "For CentOS 8.3, python bindings of firewalld, dnf, selinux are not available if python is installed from source and not from dnf. So please make sure python3.6 is installed using dnf. And ansible uses the python version 3.6 installed using dnf"
 python_version_support: '3.6.8'
 default_ansible_config_file_path: /etc/ansible/ansible.cfg
-invalid_tag_msg: "Failed. init tag can't be skipped"
+invalid_run_tag_msg: "Failed. init tag should be used with run tags"
+invalid_skip_tag_msg: "Failed. init tag can't be used with skip tags"
 
 # Usage: verify_login_inputs.yml
 login_vars_filename: "input_params/login_vars.yml"

+ 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"