From 3147e4bf780987d5862f8667c0f8977b1760399a Mon Sep 17 00:00:00 2001 From: Nicola Belluti Date: Wed, 26 Aug 2026 11:24:56 +0200 Subject: [PATCH] Added `cpu_governor` role --- roles/cpu_governor/tasks/main.yml | 80 +++++++++++++++++++ .../cpu_governor/templates/overclock.conf.j2 | 4 + site.yml | 3 + 3 files changed, 87 insertions(+) create mode 100644 roles/cpu_governor/tasks/main.yml create mode 100644 roles/cpu_governor/templates/overclock.conf.j2 diff --git a/roles/cpu_governor/tasks/main.yml b/roles/cpu_governor/tasks/main.yml new file mode 100644 index 0000000..ab057e0 --- /dev/null +++ b/roles/cpu_governor/tasks/main.yml @@ -0,0 +1,80 @@ +- name: Install build and runtime prerequisites + become: true + community.general.pacman: + name: + - git + - python-pipx + state: present + +- name: Check whether bc250-apply is already installed + ansible.builtin.command: + argv: + - which + - bc250-apply + register: bc250_apply + changed_when: false + failed_when: false + +- name: Install bc250_smu_oc + when: bc250_apply.rc != 0 + block: + - name: Create temporary dir for the checkout + ansible.builtin.tempfile: + state: directory + suffix: smuoc + register: smu_tmp + + - name: Clone bc250_smu_oc + ansible.builtin.git: + repo: https://github.com/bc250-collective/bc250_smu_oc.git + dest: "{{ smu_tmp.path }}/bc250_smu_oc" + version: main + + # pipx keeps this out of the system python environment. + - name: Install the CLI system-wide + become: true + ansible.builtin.command: + argv: + - pipx + - install + - --global + - "{{ smu_tmp.path }}/bc250_smu_oc" + + always: + - name: Remove temporary directory + become: true + ansible.builtin.file: + path: "{{ smu_tmp.path }}" + state: absent + when: smu_tmp.path is defined + +- name: Create the config directory + become: true + ansible.builtin.file: + path: /etc/bc250 + state: directory + mode: '0755' + +- name: Deploy the overclock profile + become: true + ansible.builtin.template: + src: overclock.conf.j2 + dest: /etc/bc250/overclock.conf + mode: '0644' + register: oc_conf + +- name: Install the overclock service + become: true + ansible.builtin.command: + argv: + - bc250-apply + - --install + - /etc/bc250/overclock.conf + when: oc_conf.changed + +- name: Enable the overclock service at boot + become: true + ansible.builtin.systemd_service: + name: bc250-smu-oc + enabled: true + state: started diff --git a/roles/cpu_governor/templates/overclock.conf.j2 b/roles/cpu_governor/templates/overclock.conf.j2 new file mode 100644 index 0000000..86ea725 --- /dev/null +++ b/roles/cpu_governor/templates/overclock.conf.j2 @@ -0,0 +1,4 @@ +[overclock] +frequency = 3500 +scale = -30 +max_temperature = 85 diff --git a/site.yml b/site.yml index 2a74199..6b88807 100644 --- a/site.yml +++ b/site.yml @@ -13,3 +13,6 @@ role: mesa - name: Enable 40CU role: 40cu + + - name: Install CPU governor + role: cpu_governor