From fed71d7addf5cfa2d39e1676417e91e56bd13220 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 8 Nov 2021 00:21:58 -0500 Subject: [PATCH] Add option for setting CPU governor Allows the administrator to set a CPU frequency governor if they need to, though the default of ondemand is usually sufficient. --- group_vars/default/base.yml | 4 ++++ roles/base/defaults/main.yml | 2 ++ roles/base/tasks/main.yml | 21 +++++++++++++++++-- .../templates/etc/default/cpufrequtils.j2 | 3 +++ roles/base/templates/etc/default/locale.j2 | 2 ++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 roles/base/templates/etc/default/cpufrequtils.j2 diff --git a/group_vars/default/base.yml b/group_vars/default/base.yml index 9302110..073fe69 100644 --- a/group_vars/default/base.yml +++ b/group_vars/default/base.yml @@ -19,6 +19,10 @@ recursive_dns_search_domains: # Cluster hardware model, used in pvc_user_configuration and grub_configuration below cluster_hardware: default +# CPU governor, sets power and performance statistics of the system CPUs; default is ondemand +# > Valid options are (usually): conservative, ondemand, powersave, userspace, performance, schedutil +cpu_governor: ondemand + # Debian package repository URL debian_main_repository: http://ftp.debian.org/debian debian_security_repository: http://security.debian.org diff --git a/roles/base/defaults/main.yml b/roles/base/defaults/main.yml index a6a6c57..556f952 100644 --- a/roles/base/defaults/main.yml +++ b/roles/base/defaults/main.yml @@ -19,3 +19,5 @@ deploy_username: "deploy" fail2ban_ignorelist: - 10.0.0.0/8 + +cpu_governor: "ondemand" diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index 3f80727..81f29ea 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -251,6 +251,7 @@ - lzop - xz-utils - haveged + - cpufrequtils - ipmitool - grub-efi - plymouth @@ -324,6 +325,21 @@ - /etc/sysctl.d/pvc.conf tags: base-system +# cpufreq +- name: write the cpufrequtils governor + template: + src: etc/default/cpufrequtils.j2 + dest: /etc/default/cpufrequtils + register: cpufrequtils + tags: base-system + +- name: activate cpufrequtils governor + service: + name: cpufrequtils + state: restarted + when: cpufrequtils.changed + tags: base-system + # sudo - name: write the sudoers file template: @@ -963,9 +979,10 @@ enabled: yes with_items: - acpid - - rsyslog - - postfix + - cpufrequtils - ntp + - postfix + - rsyslog - ssh tags: base-services diff --git a/roles/base/templates/etc/default/cpufrequtils.j2 b/roles/base/templates/etc/default/cpufrequtils.j2 new file mode 100644 index 0000000..dcaf142 --- /dev/null +++ b/roles/base/templates/etc/default/cpufrequtils.j2 @@ -0,0 +1,3 @@ +# CPU Frequency Utils configuration +# {{ ansible_managed }} +GOVERNOR="{{ cpu_governor }}" diff --git a/roles/base/templates/etc/default/locale.j2 b/roles/base/templates/etc/default/locale.j2 index 3944c9a..6b33922 100644 --- a/roles/base/templates/etc/default/locale.j2 +++ b/roles/base/templates/etc/default/locale.j2 @@ -1,3 +1,5 @@ +# Locales configuration +# {{ ansible_managed }} LANGUAGE=en_CA.UTF-8 LC_ALL=en_CA.UTF-8 LANG=en_CA.UTF-8