# 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: Install packages for slurm package: name: "{{ item }}" state: present with_items: - "{{ slurm_packages }}" tags: install - name: Install development tools package: name: "{{ item }}" enablerepo: PowerTools state: present with_items: - "{{ dev_tools }}" tags: install - name: Create temporary download folder for slurm file: path: "{{ tmp_path }}" owner: slurm group: slurm mode: "{{ tmp_mode }}" state: directory - name: Download slurm source get_url: url: "{{ slurm_url }}" dest: "{{ tmp_path }}" checksum: "{{ slurm_md5 }}" validate_certs: no tags: install - name: Build slurm rpms command: rpmbuild -ta "{{ rpmbuild_path }}" changed_when: false args: warn: no - name: Verify package md5 command: rpm -qa ignore_errors: true register: verify_result changed_when: no failed_when: no args: warn: no - name: Install rpms command: rpm -Uvh ~"{{ rpm_loop }}" args: chdir: "{{ rpm_path }}" warn: no when: verify_result.rc != 0 - name: Add control machine name lineinfile: path: "{{ slurm_confpth }}" regexp: "ControlMachine=" line: "ControlMachine={{ group_names[0] }}" - name: Add slurm user name lineinfile: path: "{{ slurmdbd_path }}" regexp: "SlurmUser=" line: "SlurmUser={{ slurm_user }}" - name: Firewall rule for slurm - tcp/ip,udp firewalld: zone: internal port: "{{ item }}" permanent: true state: enabled with_items: - "{{ tcp_port1 }}" - "{{ tcp_port2 }}" - "{{ tcp_port3 }}" - "{{ tcp_port4 }}" - "{{ udp_port1 }}" - "{{ udp_port2 }}" tags: install - name: Get network address/subnet mask through ipaddr 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: internal rich_rule: 'rule family="{{ family }}" source address="{{ network_address }}" accept' permanent: true state: enabled tags: install - name: Firewall reload systemd: name: firewalld state: reloaded tags: install - name: Start mariadb service: 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 'slurm'@'localhost' identified by 'password' with grant option;" tags: install changed_when: true - name: Create slurmdbd.conf file copy: src: slurmdbd.conf dest: "{{ slurmdbd_path }}" mode: "{{ slurmdbd_mode }}" 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={{ DbdAddr }}" - name: Add db host lineinfile: path: "{{ slurmdbd_path }}" regexp: "DbdHost=" line: "DbdHost={{ DbdHost }}" - 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: Populate accounting database command: slurmdbd tags: install changed_when: true - name: Save slurm conf file in buffer fetch: src: "{{ slurm_confpth }}" dest: "{{ buffer_path }}" flat: true