summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlinxin <[email protected]>2024-11-08 09:36:15 +0800
committerlinxin <[email protected]>2024-11-08 09:36:15 +0800
commit32c2d07827e8252ff06f74696d2319b3ea01de9d (patch)
treec84a27b3101e806482a06c54f95a45e0b2e0d1bd
parent9d44409f3cb3b14b439f08cf359da8ae640cdb35 (diff)
parent916f6ced45ddc74aa96ae97cc0fb10e65da0caff (diff)
Merge branch 'feature-os-adapte-aarch64-arch' of git.mesalab.cn:tsg/tsg-os-buildimage into feature-os-adapte-aarch64-arch
-rw-r--r--ansible/HAL_deploy.yml3
-rwxr-xr-xansible/roles/OFED/files/uname11
-rw-r--r--ansible/roles/OFED/files/uname_hook.sh48
-rw-r--r--ansible/roles/OFED/tasks/main.yml89
4 files changed, 75 insertions, 76 deletions
diff --git a/ansible/HAL_deploy.yml b/ansible/HAL_deploy.yml
index 34dabd24..ceb507d2 100644
--- a/ansible/HAL_deploy.yml
+++ b/ansible/HAL_deploy.yml
@@ -23,4 +23,5 @@
- {role: tuned, tags: tuned}
- {role: tsg-os-oobc, tags: tsg-os-oobc}
- {role: tsg-os-logfile-cleaner, tags: tsg-os-logfile-cleaner}
- - {role: qemu-user-static, tags: qemu-user-static} \ No newline at end of file
+ - {role: qemu-user-static, tags: qemu-user-static}
+ - {role: OFED, tags: OFED} \ No newline at end of file
diff --git a/ansible/roles/OFED/files/uname b/ansible/roles/OFED/files/uname
index 8a89026d..fcf1dc5a 100755
--- a/ansible/roles/OFED/files/uname
+++ b/ansible/roles/OFED/files/uname
@@ -1,8 +1,13 @@
#!/bin/sh
-if [ "$1" == "-r" ]
-then
- echo KERNEL_VERSION.x86_64
+if [ "$1" == "-r" ]; then
+ # In case multiple versions of the kernel are installed here, the first version is used by default
+ # KERNEL_VERSION=$(rpm -q kernel --qf "%{VERSION}-%{RELEASE}.%{ARCH}\n" | tail -n 1)
+
+ # Use the rpm command to query the information of the rpm package, which requires that the package must be installed.
+ # Use dnf info to query to avoid installing the kernel.
+ KERNEL_VERSION=$(dnf info kernel | awk '/Version/{version=$3} /Release/{release=$3} /Architecture/{arch=$3} END{print version "-" release "." arch}')
+ echo "$KERNEL_VERSION"
else
/usr/bin/uname-backup $1
fi
diff --git a/ansible/roles/OFED/files/uname_hook.sh b/ansible/roles/OFED/files/uname_hook.sh
new file mode 100644
index 00000000..58c7a953
--- /dev/null
+++ b/ansible/roles/OFED/files/uname_hook.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+# Function to print help information
+print_help() {
+ echo "Usage: $0 --hook | --recover | --help"
+ echo
+ echo "--hook : Backs up /usr/bin/uname and replaces it with the uname file from the script directory, setting permissions to 0755."
+ echo "--recover : Restores /usr/bin/uname from the backup if /usr/bin/uname-backup exists."
+ echo "--help : Displays this help message."
+ exit 0
+}
+
+# Check the input argument
+if [ "$1" == "--hook" ]; then
+ # Argument is --hook
+ if [ -f /usr/bin/uname-backup ]; then
+ echo "/usr/bin/uname-backup already exists. Skipping backup and replacement."
+ else
+ if [ -f /usr/bin/uname ]; then
+ # Backup the original /usr/bin/uname
+ cp /usr/bin/uname /usr/bin/uname-backup
+ echo "/usr/bin/uname has been backed up as /usr/bin/uname-backup"
+ fi
+ # Copy the uname file from the script directory to /usr/bin/ and set permissions to 0755
+ cp "$(dirname "$0")/uname" /usr/bin/uname
+ chmod 0755 /usr/bin/uname
+ echo "The uname file from the script directory has been copied to /usr/bin/uname with permissions set to 0755"
+ fi
+
+elif [ "$1" == "--recover" ]; then
+ # Argument is --recover
+ if [ -f /usr/bin/uname-backup ]; then
+ # If backup exists, remove current /usr/bin/uname and restore the backup
+ rm -f /usr/bin/uname
+ mv /usr/bin/uname-backup /usr/bin/uname
+ echo "/usr/bin/uname has been restored from the backup"
+ else
+ echo "/usr/bin/uname-backup does not exist, cannot restore"
+ fi
+
+elif [ "$1" == "--help" ]; then
+ # Display help
+ print_help
+else
+ # Invalid argument or no argument
+ echo "Invalid or missing argument."
+ print_help
+fi \ No newline at end of file
diff --git a/ansible/roles/OFED/tasks/main.yml b/ansible/roles/OFED/tasks/main.yml
index 6e19eef7..ca0f5517 100644
--- a/ansible/roles/OFED/tasks/main.yml
+++ b/ansible/roles/OFED/tasks/main.yml
@@ -1,81 +1,26 @@
---
-- name: "Copy MFT installer package to to destination server"
+- name: Add doca-ofed repository
+ yum_repository:
+ name: doca
+ description: DOCA Online Repo
+ file: doca
+ baseurl: https://linux.mellanox.com/public/repo/doca/2.8.0/rhel9.4/arm64-sbsa/
+ gpgcheck: no
+
+- name: "Copy file to to destination server"
copy:
src: "{{ role_path }}/files/"
dest: "/tmp/mft/"
-- name: "Create unarchive directory"
- file:
- path: "/tmp/mft/unarchived"
- state: directory
-
- name: "Backup and Replace the uname tools"
- copy:
- src: "{{ item.src }}"
- dest: "{{ item.dest }}"
- mode: "{{ item.mode }}"
- remote_src: yes
- with_items:
- - { src: "/usr/bin/uname" , dest: "/usr/bin/uname-backup" , mode: "0755" }
- - { src: "/tmp/mft/uname" , dest: "/usr/bin/uname" , mode: "0755" }
-
-- name: "Change kernel version for uname"
- shell: sed -i -e 's/KERNEL_VERSION/5.17.15-1.el8/' /usr/bin/uname
- when: runtime_env == 'TSG-X-P0906'
-
-############ Ofed kernel only install ############
-- name: "Install mlnx-ofed-kernel-only"
- yum:
- name: "mlnx-ofed-kernel-only-all-5.17.15-1.el8.x86_64.noarch"
- conf_file: "{{ rpm_repo_config_path }}"
- state: present
-######################### end #########################
-
-############ MFT install start ############
-- name: "Unarchive mft RPM"
- unarchive:
- src: /tmp/mft/mft-4.22.1-11-x86_64-rpm.tgz
- dest: /tmp/mft/unarchived/
- remote_src: yes
-
-- name: "Execute MFT installer"
- shell: /tmp/mft/unarchived/mft-4.22.1-11-x86_64-rpm/install.sh
-######################### end #########################
+ shell: bash /tmp/mft/uname_hook.sh --hook
+ args:
+ executable: /bin/bash
-############ MLNX FW UPDATER install start ############
-- name: "Install mlnx-fw-updater rpm package"
- shell: rpm -i /tmp/mft/mlnx-fw-updater-5.8-2.0.3.0.x86_64.rpm
-######################### end #########################
+- name: "Install doca-ofed"
+ shell: dnf -y install doca-ofed
-############ Set RUN_FW_UPDATER_ONBOOT ############
-- name: "Enable auto update firmware on boot"
- lineinfile:
- path: /etc/infiniband/openib.conf
- regexp: '^RUN_FW_UPDATER_ONBOOT'
- line: "RUN_FW_UPDATER_ONBOOT=no"
-######################### end #########################
-
-###### Restore the uname tools ######
- name: "Restore the uname tools"
- copy:
- src: "/usr/bin/uname-backup"
- dest: "/usr/bin/uname"
- mode: "0755"
- remote_src: yes
-######################### end #########################
-
-###### Enable dropless rq ######
-- name: "Set the udev rule"
- copy:
- src: "/tmp/mft/90-nvidia-cx6-enable-dropless-rq.rules"
- dest: "/usr/lib/udev/rules.d/90-nvidia-cx6-enable-dropless-rq.rules"
- mode: "0644"
- remote_src: yes
-
-- name: "Copy the 'enable_dropless_rq.sh' "
- copy:
- src: "/tmp/mft/enable_dropless_rq.sh"
- dest: "/usr/local/sbin/enable_dropless_rq.sh"
- mode: "0755"
- remote_src: yes
-######################### end ######################### \ No newline at end of file
+ shell: bash /tmp/mft/uname_hook.sh --recover
+ args:
+ executable: /bin/bash