Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions utils/create_slurm_repo.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a example for inventory

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 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: Prepare the cluster with passwordless ssh from manager to compute
hosts: localhost
gather_facts: false
any_errors_fatal: true
roles:
- create_slurm_repo
36 changes: 36 additions & 0 deletions utils/roles/create_slurm_repo/tasks/build_rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2025 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: Verify Slurm tarball exists
ansible.builtin.stat:
path: "{{ slurm_base }}/{{ slurm_tarball }}"
register: slurm_tarball_check

- name: Fail if Slurm tarball is missing
ansible.builtin.fail:
msg: "Slurm source tarball not found at {{ slurm_base }}/{{ slurm_tarball }}."
when: not slurm_tarball_check.stat.exists

- name: Run rpmbuild for Slurm (This task may take few minutes)
ansible.builtin.shell: >
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ARM also considered for build

rpmbuild -ta {{ slurm_base }}/{{ slurm_tarball }}
--define "_topdir {{ rpmbuild_dir }}"
--define "_configure_args {{ slurm_configure_args | join(' ') }}
--with-nvml={{ slurm_nvml_config.path }}"
> "{{ log_dir }}/rpm_build.log" 2>&1
args:
chdir: "{{ slurm_base }}"
register: rpmbuild_result
changed_when: rpmbuild_result.rc == 0
failed_when: rpmbuild_result.rc != 0
32 changes: 32 additions & 0 deletions utils/roles/create_slurm_repo/tasks/clean_up.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2025 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: Announce cleanup
ansible.builtin.debug:
msg: "Cleaning up Slurm build environment at {{ slurm_base }}"

- name: Check if Slurm base directory exists
ansible.builtin.stat:
path: "{{ slurm_base }}"
register: slurm_dir

- name: Remove Slurm base directory
ansible.builtin.file:
path: "{{ slurm_base }}"
state: absent
when: slurm_dir.stat.exists

- name: Confirm cleanup complete
ansible.builtin.debug:
msg: "Cleanup complete."
49 changes: 49 additions & 0 deletions utils/roles/create_slurm_repo/tasks/copy_rpms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2025 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: Remove existing destination directory if present
ansible.builtin.file:
path: "{{ dest_repo_path }}"
state: absent

- name: Create destination directory
ansible.builtin.file:
path: "{{ dest_repo_path }}"
state: directory
owner: apache
group: apache
mode: "{{ repo_dir_mode }}"

- name: Copy RPMs from source to destination
ansible.builtin.copy:
src: "{{ source_rpm_path }}/"
dest: "{{ dest_repo_path }}/"
owner: apache
group: apache
mode: '0644'
remote_src: false

- name: Install createrepo if not installed
ansible.builtin.dnf:
name: createrepo
state: present

- name: Create repo metadata
ansible.builtin.command: createrepo --update "{{ dest_repo_path }}"
args:
creates: "{{ dest_repo_path }}/repodata"

- name: Display success message
ansible.builtin.debug:
msg: "Slurm RPM repository successfully created and accessible at http://{{ ansible_host | default(inventory_hostname) }}/slurm_rpms/"
23 changes: 23 additions & 0 deletions utils/roles/create_slurm_repo/tasks/create_dirs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2025 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: Ensure base, rpmbuild, and log directories exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: "{{ repo_dir_mode }}"
loop:
- "{{ slurm_base }}"
- "{{ rpmbuild_dir }}"
- "{{ log_dir }}"
32 changes: 32 additions & 0 deletions utils/roles/create_slurm_repo/tasks/download_tarball.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2025 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: Ensure Slurm base directory exists
ansible.builtin.file:
path: "{{ slurm_base }}"
state: directory
mode: "{{ repo_dir_mode }}"

- name: Download Slurm source tarball
ansible.builtin.get_url:
url: "{{ slurm_download_url }}"
dest: "{{ slurm_base }}/{{ slurm_tarball }}"
mode: '0644'
force: true
register: download_result

- name: Verify download success
ansible.builtin.fail:
msg: "Failed to download {{ slurm_tarball }} from {{ slurm_download_url }}"
when: download_result is failed
60 changes: 60 additions & 0 deletions utils/roles/create_slurm_repo/tasks/install_apache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2025 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: Ensure Apache (httpd) is installed
ansible.builtin.dnf:
name: httpd
state: present

- name: Enable and start Apache service
ansible.builtin.service:
name: httpd
state: started
enabled: true

- name: Allow HTTP service in the firewall
ansible.posix.firewalld:
service: http
permanent: true
state: enabled
immediate: true

- name: Confirm Apache is listening on port 80
ansible.builtin.wait_for:
port: "{{ apache_config.port | int }}"
state: started
timeout: 10
changed_when: false

- name: Ensure Apache is installed and running
ansible.builtin.dnf:
name: httpd
state: present

- name: Ensure /var/www/html exists
ansible.builtin.file:
path: "{{ html_repo_path }}"
state: directory
owner: apache
group: apache
mode: "{{ repo_dir_mode }}"

- name: Restore SELinux context on /var/www/html (if enabled)
ansible.builtin.command: restorecon -Rv {{ html_repo_path }}
when: ansible_selinux is defined and ansible_selinux.status == "enabled"
changed_when: false

- name: Display success message
ansible.builtin.debug:
msg: "Apache successfully installed and serving"
31 changes: 31 additions & 0 deletions utils/roles/create_slurm_repo/tasks/install_dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2025 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: Update package metadata
ansible.builtin.dnf:
name: "*"
state: latest
update_only: true

- name: Install Slurm build dependencies
ansible.builtin.yum:
name: "{{ slurm_dependencies.common_pkg + slurm_dependencies.tools_pkg + slurm_dependencies.slurm_pkg }}"
state: present
register: install_result

- name: Fail play if dependency installation failed
ansible.builtin.fail:
msg: "Slurm dependency installation failed on {{ inventory_hostname }}!"
when: install_result is failed
27 changes: 27 additions & 0 deletions utils/roles/create_slurm_repo/tasks/install_sshpass.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file if not used

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2025 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 sshpass
ansible.builtin.dnf:
name: sshpass
state: present

- name: Verify sshpass installation
ansible.builtin.command: sshpass -V
register: sshpass_version
changed_when: false

- name: Display sshpass installation status
ansible.builtin.debug:
msg: "sshpass installed successfully"
56 changes: 56 additions & 0 deletions utils/roles/create_slurm_repo/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2025 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.
---
# Play 1 Tasks - Executed on localhost (Control Node)
- name: Install sshpass
ansible.builtin.include_tasks: install_sshpass.yml

- name: Clean up previous build
ansible.builtin.include_tasks: clean_up.yml

- name: Create directory structure
ansible.builtin.include_tasks: create_dirs.yml

- name: Install dependencies
ansible.builtin.include_tasks: install_dependencies.yml

- name: Download Slurm source tarball
ansible.builtin.include_tasks: download_tarball.yml

- name: Build Slurm RPM package
ansible.builtin.include_tasks: build_rpm.yml

# Play 2 Tasks - Executed on Delegated Apache Host
- name: Collect installed rpm package facts
delegate_to: "{{ groups['apache_server'][0] }}"
run_once: true
ansible.builtin.package_facts:

- name: Check if Apache is already installed on apache_server
ansible.builtin.set_fact:
apache_installed: "{{ apache_pkg in ansible_facts.packages }}"
delegate_to: "{{ groups['apache_server'][0] }}"
run_once: true

- name: Slurm Repo creation tasks on Apache Server
delegate_to: "{{ groups['apache_server'][0] }}"
run_once: true
block:

- name: Install and configure Apache (only if not installed)
ansible.builtin.include_tasks: install_apache.yml
when: not apache_installed | bool

- name: Copy Slurm RPMs and create repository
ansible.builtin.include_tasks: copy_rpms.yml
Loading