main.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. service:
  35. name: slurmdbd
  36. state: restarted
  37. tags: install
  38. - name: Start slurmctld on manager
  39. service:
  40. name: slurmctld
  41. state: started
  42. tags: install
  43. - name: Show cluster if exists
  44. command: sacctmgr -n show cluster {{ cluster_name }}
  45. register: slurm_clusterlist
  46. changed_when: false
  47. - name: Create slurm cluster
  48. command: sacctmgr -i add cluster {{ cluster_name }}
  49. when: not slurm_clusterlist.stdout
  50. - name: Show account
  51. command: sacctmgr show account -s
  52. register: account_added
  53. changed_when: false
  54. - name: Create default slurm group
  55. command: sacctmgr -i add account defaultgroup Cluster={{ cluster_name }} Description="Default Account" Organization="Default Org"
  56. when: account_added.rc != 0
  57. - name: Check if user exists
  58. command: sacctmgr show user -s
  59. register: user_added
  60. changed_when: false
  61. - name: Add root to the default account
  62. command: sacctmgr -i add user root DefaultAccount=defaultgroup
  63. when: user_added.rc != 0