From 61943909810aa3a8e4eb1d1cac06208388a0aae7 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Fri, 20 Dec 2024 18:19:28 +0100 Subject: [PATCH] feat(ansible): install amdgpu drivers and packages on sles --- .vscode/settings.json | 6 +++- ansible/playbooks/amdgpu.install.yml | 49 ++++++++++++++++++++++++++++ knowledge base/ansible.md | 14 ++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 ansible/playbooks/amdgpu.install.yml diff --git a/.vscode/settings.json b/.vscode/settings.json index 85ea9d8..fd13810 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -75,6 +75,7 @@ "airgap", "airgapped", "alertmanager", + "amdgpu", "apiserver", "asciicast", "asciinema", @@ -294,6 +295,7 @@ "ripsecrets", "rmmod", "roboto", + "rocm", "roff", "rootlv", "rootvg", @@ -312,6 +314,7 @@ "setfattr", "sidekiq", "siem", + "sles", "slurm", "snmp", "spiffe", @@ -373,6 +376,7 @@ "yellowdog", "ykman", "yubikey", - "zstd" + "zstd", + "zypp" ] } \ No newline at end of file diff --git a/ansible/playbooks/amdgpu.install.yml b/ansible/playbooks/amdgpu.install.yml new file mode 100644 index 0000000..96a8dfb --- /dev/null +++ b/ansible/playbooks/amdgpu.install.yml @@ -0,0 +1,49 @@ +--- + +- name: Install AMDGPU drivers and applications + hosts: all + vars: + drivers_version: 6.3 + distribution_version: "{{ ansible_distribution_version }}" + architecture: "{{ ansible_architecture }}" + tasks: + - name: Install AMDGPU drivers and applications on SLES + # refer https://rocm.docs.amd.com/projects/install-on-linux/en/latest/install/native-install/sles.html + tags: sles + when: + - ansible_pkg_mgr | lower in ['zypper'] + - ansible_distribution_file_variety | lower in ['suse'] + block: + - name: Add the AMDGPU kernel-mode driver repository on SLES + tags: repository + become: true + ansible.builtin.copy: + dest: /etc/zypp/repos.d/amdgpu.repo + content: | + [amdgpu] + name=amdgpu + baseurl=https://repo.radeon.com/amdgpu/{{ drivers_version }}/sle/{{ distribution_version }}/main/{{ architecture }}/ + enabled=1 + gpgcheck=1 + gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key + - name: Add the AMDGPU ROCm packages repository on SLES + tags: repository + become: true + ansible.builtin.copy: + dest: /etc/zypp/repos.d/rocm.repo + content: | + [ROCm-{{ drivers_version }}] + name=ROCm{{ drivers_version }} + baseurl=https://repo.radeon.com/rocm/zyp/{{ drivers_version }}/main + enabled=1 + gpgcheck=1 + gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key + - name: Install AMDGPU packages on SLES + tags: package + become: true + community.general.zypper: + name: + - amdgpu-dkms + - rocm + disable_recommends: false + update_cache: true diff --git a/knowledge base/ansible.md b/knowledge base/ansible.md index 6531802..9ef0a47 100644 --- a/knowledge base/ansible.md +++ b/knowledge base/ansible.md @@ -28,6 +28,7 @@ 1. [Ansible Vault](#ansible-vault) 1. [Best practices](#best-practices) 1. [Troubleshooting](#troubleshooting) + 1. [ERROR: Ansible could not initialize the preferred locale: unsupported locale setting](#error-ansible-could-not-initialize-the-preferred-locale-unsupported-locale-setting) 1. [Print all known variables](#print-all-known-variables) 1. [Force notified handlers to run at a specific point](#force-notified-handlers-to-run-at-a-specific-point) 1. [Time tasks execution](#time-tasks-execution) @@ -1139,6 +1140,17 @@ Or even edit their content with `ansible-vault edit 'path/to/file'`. ## Troubleshooting +### ERROR: Ansible could not initialize the preferred locale: unsupported locale setting + +`ansible-core` requires the locale to have `UTF-8` encoding [since 2.14.0][ansible v2.14 CHANGELOG]: + +> ansible - At startup the filesystem encoding and locale are checked to verify they are UTF-8. If not, the process +> exits with an error reporting the errant encoding. + +```sh +LANG='C.UTF-8' ansible … +``` + ### Print all known variables Print the special variable `vars` as a task: @@ -1494,6 +1506,7 @@ Solution: use a version of `ansible-core` lower than 2.17. - [Patterns: targeting hosts and groups] - [How to use ansible with S3 - Ansible aws_s3 examples] - [How to run Ansible with_fileglob in alphabetical order?] +- [Ansible v2.14 CHANGELOG]