|
@@ -0,0 +1,90 @@
|
|
|
+# Copyright 2022 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: Create inventory in awx
|
|
|
+ hosts: manager, compute
|
|
|
+ tasks:
|
|
|
+ - name: Check slurmctld service
|
|
|
+ systemd:
|
|
|
+ name: slurmctld
|
|
|
+ register: slurm_service_status
|
|
|
+
|
|
|
+ - name: Set fact slurm_service
|
|
|
+ set_fact:
|
|
|
+ slurm_service: True
|
|
|
+ delegate_to: localhost
|
|
|
+ when: "slurm_service_status.status.ActiveState == 'active'"
|
|
|
+
|
|
|
+ - name: Set fact slurm_service
|
|
|
+ set_fact:
|
|
|
+ slurm_service: False
|
|
|
+ delegate_to: localhost
|
|
|
+ when: "slurm_service_status.status.ActiveState == 'inactive'"
|
|
|
+
|
|
|
+ - name: Replace input file
|
|
|
+ copy:
|
|
|
+ src: "input_config.yml"
|
|
|
+ dest: /mnt/omnia/slurm/monster/config.yml
|
|
|
+ mode: 0644
|
|
|
+ delegate_to: localhost
|
|
|
+ when: "slurm_service_status.status.ActiveState == 'active'"
|
|
|
+
|
|
|
+ - name: Prepare input config file
|
|
|
+ block:
|
|
|
+ - name: Get service tag
|
|
|
+ shell: >
|
|
|
+ set -o pipefail && \
|
|
|
+ dmidecode -t 1 | grep Serial
|
|
|
+ changed_when: false
|
|
|
+ register: service_tag_details
|
|
|
+
|
|
|
+ - name: Set fact service tag
|
|
|
+ set_fact:
|
|
|
+ service_tag: "{{ service_tag_details.stdout.split(':')[1].strip() }}"
|
|
|
+
|
|
|
+ - name: Get the hostname
|
|
|
+ command: hostname
|
|
|
+ register: machine_hostname
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+ - name: Update Head Node IP
|
|
|
+ replace:
|
|
|
+ path: /mnt/omnia/slurm/monster/config.yml
|
|
|
+ regexp: ' ip:.*'
|
|
|
+ replace: " ip: {{ groups['manager'][0] }}"
|
|
|
+ delegate_to: localhost
|
|
|
+
|
|
|
+ - name: Update Head Node hostname
|
|
|
+ replace:
|
|
|
+ path: /mnt/omnia/slurm/monster/config.yml
|
|
|
+ regexp: ' headnode:.*'
|
|
|
+ replace: " headnode: {{ hostvars[groups['manager'][0]]['machine_hostname'].stdout }}"
|
|
|
+ delegate_to: localhost
|
|
|
+
|
|
|
+ - name: Update nodes hostnames
|
|
|
+ lineinfile:
|
|
|
+ path: /mnt/omnia/slurm/monster/config.yml
|
|
|
+ line: " {{ machine_hostname.stdout }}: {{ ansible_default_ipv4.address }}"
|
|
|
+ insertafter: "hostnames:"
|
|
|
+ delegate_to: localhost
|
|
|
+
|
|
|
+ - name: Update service tag info
|
|
|
+ lineinfile:
|
|
|
+ path: /mnt/omnia/slurm/monster/config.yml
|
|
|
+ line: " - Servicetag: {{ service_tag }}\n Os_Ip_Addr: {{ ansible_default_ipv4.address }}"
|
|
|
+ insertafter: "clusternodes:"
|
|
|
+ delegate_to: localhost
|
|
|
+ when: hostvars[groups['manager'][0]]['slurm_service']
|