123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- # Copyright 2020 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: Give slurm user permission to slurmctld spool
- file:
- path: "{{ spool_slurmctld_pth }}"
- owner: slurm
- group: slurm
- mode: "{{ tmp_mode }}"
- state: touch
- - name: Give slurm ownership to cluster state
- file:
- path: "{{ cluster_state_path }}"
- owner: slurm
- group: slurm
- mode: "{{ tmp_mode }}"
- state: touch
- - name: Create slurmctld log file on manager
- file:
- path: "{{ slurm_logpth }}"
- owner: slurm
- mode: "{{ tmp_mode }}"
- state: touch
- with_items:
- - slurmctld.log
- - name: Create log files on manager
- file:
- path: "{{ slurm_logpth }}"
- owner: slurm
- mode: "{{ tmp_mode }}"
- state: touch
- with_items:
- - "{{ log_files_manager }}"
- - name: Install packages for slurm
- package:
- name: "{{ slurm_packages }}"
- state: present
- tags: install
- - name: Install development tools
- package:
- name: "{{ dev_tools }}"
- state: present
- tags: install
- - name: Get the hostname
- command: hostname
- register: machine_name
- changed_when: true
- - name: Add control machine name
- lineinfile:
- path: "{{ slurm_confpth }}"
- regexp: "ControlMachine="
- line: "ControlMachine={{ machine_name.stdout }}"
- - name: Add slurm user name
- lineinfile:
- path: "{{ slurm_confpth }}"
- regexp: "SlurmUser="
- line: "SlurmUser={{ slurm_user }}"
- - name: Install firewalld
- package:
- name: firewalld
- state: present
- tags: firewalld
- - name: Start and enable firewalld
- service:
- name: firewalld
- state: started
- enabled: yes
- tags: firewalld
- - name: Firewall rule for slurm - tcp/udp ports
- firewalld:
- zone: public
- port: "{{ item }}"
- permanent: true
- state: enabled
- with_items:
- - "{{ tcp_port1 }}"
- - "{{ tcp_port2 }}"
- - "{{ tcp_port3 }}"
- - "{{ tcp_port4 }}"
- - "{{ udp_port3 }}"
- - "{{ udp_port1 }}"
- - "{{ udp_port2 }}"
- when: "'manager' in group_names"
- tags: firewalld
- - name: Get network address/subnet mask
- set_fact:
- network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('network/prefix') }}"
- - name: Firewall rule slurm - allow all incoming traffic on internal network
- firewalld:
- zone: public
- rich_rule: 'rule family="{{ family }}" source address="{{ network_address }}" accept'
- permanent: true
- state: enabled
- tags: firewalld
- - name: Reload firewalld
- command: firewall-cmd --reload
- changed_when: true
- tags: firewalld
- - name: Start mariadb
- systemd:
- name: mariadb
- state: restarted
- enabled: yes
- tags: install
- - name: Grant permissions for slurm db
- command: >-
- mysql -u root -e "GRANT ALL ON slurm_acct_db.* TO '{{ db_user }}'@'{{
- db_host }}' identified by '{{ hostvars['127.0.0.1']['db_password'] }}'with
- grant option;"
- tags: install
- changed_when: true
- - name: Create slurmdbd.conf file
- copy:
- src: slurmdbd.conf
- dest: "{{ slurmdbd_path }}"
- mode: "{{ slurmdbd_mode }}"
- owner: slurm
- tags: install
- - name: Add slurm user name
- lineinfile:
- path: "{{ slurmdbd_path }}"
- regexp: "SlurmUser="
- line: "SlurmUser={{ slurm_user }}"
- - name: Add db address
- lineinfile:
- path: "{{ slurmdbd_path }}"
- regexp: "DbdAddr="
- line: "DbdAddr={{ dbd_addr }}"
- - name: Add db host
- lineinfile:
- path: "{{ slurmdbd_path }}"
- regexp: "DbdHost="
- line: "DbdHost={{ dbd_host }}"
- - name: Add storage password
- lineinfile:
- path: "{{ slurmdbd_path }}"
- regexp: "StoragePass="
- line: "StoragePass={{ hostvars['127.0.0.1']['db_password'] }}"
- - name: Add storage user
- lineinfile:
- path: "{{ slurmdbd_path }}"
- regexp: "StorageUser="
- line: "StorageUser={{ slurm_user }}"
- - name: Add log file path
- lineinfile:
- path: "{{ slurmdbd_path }}"
- regexp: "LogFile="
- line: "LogFile={{ logfile }}"
- - name: Add pid file path
- lineinfile:
- path: "{{ slurmdbd_path }}"
- regexp: "PidFile="
- line: "PidFile={{ pidfile }}"
- - name: Save slurm conf file in buffer
- fetch:
- src: "{{ slurm_confpth }}"
- dest: "{{ buffer_path }}"
- flat: true
|