generate_token.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Generate key
  16. command: dd if=/dev/random of="{{ token_dir }}" bs=32 count=1
  17. changed_when: false
  18. - name: Copy the key to /etc/slurm
  19. copy:
  20. src: "{{ token_dir }}"
  21. dest: "{{ slurm_dir }}"
  22. owner: slurm
  23. group: slurm
  24. mode: "{{ token_mode }}"
  25. remote_src: yes
  26. - name: Add authentication alt type entry in slurm.conf
  27. lineinfile:
  28. path: "{{ slurm_conf_path }}"
  29. insertafter: 'AuthType=auth/munge\n'
  30. line: 'AuthAltTypes=auth/jwt'
  31. - name: Add auth alt parameter entry in slurm.conf
  32. lineinfile:
  33. path: "{{ slurm_conf_path }}"
  34. insertafter: 'AuthAltTypes=auth/jwt\n'
  35. line: 'AuthAltParameters=jwt_key=/etc/slurm/jwt_hs256.key'
  36. - name: Restart slurmctld
  37. systemd:
  38. name: slurmctld
  39. state: restarted
  40. daemon_reload: yes
  41. enabled: yes
  42. - name: Create systemd unit file
  43. copy:
  44. src: "{{ role_path }}/files/slurm-restd-custom.service"
  45. dest: "{{ systemd_path_dest }}"
  46. remote_src: no
  47. mode: "{{ fil_mode }}"
  48. - name: Fetch hostname
  49. command: hostname
  50. register: current_hostname
  51. changed_when: false
  52. - name: Set fact for server hostname
  53. set_fact:
  54. manager_hostname: "{{ current_hostname.stdout }}"
  55. - name: Update the port in service file
  56. replace:
  57. path: "{{ systemd_path_dest }}/slurm-restd-custom.service"
  58. regexp: "0.0.0.0:6820"
  59. replace: "{{ manager_hostname }}:{{ slurm_restd_port }}"
  60. - name: Add random token
  61. shell: set -o pipefail && export SLURM_JWT=nvisjvopaekgvgoawkgvpao84r93fjmdkvmdkvm
  62. changed_when: false
  63. - name: Start services
  64. systemd:
  65. name: slurm-restd-custom.service
  66. state: restarted
  67. enabled: yes