main.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Copyright 2020 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: Include common variables
  16. include_vars: ../../slurm_manager/vars/main.yml
  17. - name: Include common variables
  18. include_vars: ../../slurm_common/vars/main.yml
  19. - name: Copy slurm conf from buffer
  20. copy:
  21. src: "{{ buffer_path }}"
  22. dest: "{{ slurm_confpth }}"
  23. mode: "{{ slurm_mode }}"
  24. - name: Add compute hosts info in hosts file
  25. lineinfile:
  26. dest: "{{ hosts_dest }}"
  27. line: "{{ hostvars[item].compute_host }} {{ hostvars[item].compute_ip }}"
  28. state: present
  29. create: yes
  30. mode: "{{ common_mode }}"
  31. with_items:
  32. - "{{ groups['compute'] }}"
  33. - name: Enable slurmdbd on manager
  34. systemd:
  35. name: slurmdbd
  36. state: restarted
  37. enabled: yes
  38. tags: install
  39. - name: Start slurmctld on manager
  40. systemd:
  41. name: slurmctld
  42. state: restarted
  43. enabled: yes
  44. tags: install
  45. - name: Show cluster if exists
  46. command: sacctmgr -n show cluster {{ cluster_name }}
  47. register: slurm_clusterlist
  48. changed_when: false
  49. - name: Create slurm cluster
  50. command: sacctmgr -i add cluster {{ cluster_name }}
  51. when: not slurm_clusterlist.stdout
  52. - name: Show account
  53. command: sacctmgr show account -s
  54. register: account_added
  55. changed_when: false
  56. - name: Create default slurm group
  57. command: sacctmgr -i add account defaultgroup Cluster={{ cluster_name }} Description="Default Account" Organization="Default Org"
  58. when: account_added.rc != 0
  59. - name: Check if user exists
  60. command: sacctmgr show user -s
  61. register: user_added
  62. changed_when: false
  63. - name: Add root to the default account
  64. command: sacctmgr -i add user root DefaultAccount=defaultgroup
  65. when: user_added.rc != 0