From 923768917bb1632099ddefe89e797a21fa663ebf Mon Sep 17 00:00:00 2001
From: Kristian Klausen <kristian@klausen.dk>
Date: Sat, 27 Jul 2024 19:43:54 +0200
Subject: [PATCH] Revert "Limit Borg CPU usage on single vCPU servers to 50%"

This reverts commit f5b566fabbc07464d3b3a9b506b890ce15b82e9a.

We no longer have cloud servers with 1-vCPU so this isn't needed.
---
 .../borg-backup-offsite.service}                          | 1 -
 .../borg-backup.service.j2 => files/borg-backup.service}  | 1 -
 roles/borg_client/tasks/main.yml                          | 8 +++-----
 roles/borg_client/templates/borg-backup-cpu-quota.j2      | 4 ----
 4 files changed, 3 insertions(+), 11 deletions(-)
 rename roles/borg_client/{templates/borg-backup-offsite.service.j2 => files/borg-backup-offsite.service} (73%)
 rename roles/borg_client/{templates/borg-backup.service.j2 => files/borg-backup.service} (80%)
 delete mode 100644 roles/borg_client/templates/borg-backup-cpu-quota.j2

diff --git a/roles/borg_client/templates/borg-backup-offsite.service.j2 b/roles/borg_client/files/borg-backup-offsite.service
similarity index 73%
rename from roles/borg_client/templates/borg-backup-offsite.service.j2
rename to roles/borg_client/files/borg-backup-offsite.service
index 73bc8ad1b..5321ca84e 100644
--- a/roles/borg_client/templates/borg-backup-offsite.service.j2
+++ b/roles/borg_client/files/borg-backup-offsite.service
@@ -3,5 +3,4 @@ Description=Borg backup (offsite)
 
 [Service]
 Type=oneshot
-{% include 'borg-backup-cpu-quota.j2' %}
 ExecStart=/usr/local/bin/borg-backup-offsite.sh
diff --git a/roles/borg_client/templates/borg-backup.service.j2 b/roles/borg_client/files/borg-backup.service
similarity index 80%
rename from roles/borg_client/templates/borg-backup.service.j2
rename to roles/borg_client/files/borg-backup.service
index be2d3450d..616b10e93 100644
--- a/roles/borg_client/templates/borg-backup.service.j2
+++ b/roles/borg_client/files/borg-backup.service
@@ -6,5 +6,4 @@ Before=borg-backup-offsite.service
 
 [Service]
 Type=oneshot
-{% include 'borg-backup-cpu-quota.j2' %}
 ExecStart=/usr/local/bin/borg-backup.sh
diff --git a/roles/borg_client/tasks/main.yml b/roles/borg_client/tasks/main.yml
index 6311f9893..d0848d5a4 100644
--- a/roles/borg_client/tasks/main.yml
+++ b/roles/borg_client/tasks/main.yml
@@ -48,14 +48,12 @@
     - name: Create mysql backup directory
       file: path={{ backup_mysql_dir }} state=directory owner=root group=root mode=0755
 
-- name: Install systemd services for backup
-  template: src={{ item }}.j2 dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
+- name: Install systemd timer and services for backup
+  copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
   with_items:
+    - borg-backup.timer
     - borg-backup.service
     - borg-backup-offsite.service
 
-- name: Install systemd timer for backup
-  copy: src=borg-backup.timer dest=/etc/systemd/system/borg-backup.timer owner=root group=root mode=0644
-
 - name: Activate systemd timer for backup
   systemd: name=borg-backup.timer enabled=yes state=started daemon-reload=yes
diff --git a/roles/borg_client/templates/borg-backup-cpu-quota.j2 b/roles/borg_client/templates/borg-backup-cpu-quota.j2
deleted file mode 100644
index 5d264b345..000000000
--- a/roles/borg_client/templates/borg-backup-cpu-quota.j2
+++ /dev/null
@@ -1,4 +0,0 @@
-{% if ansible_processor_vcpus == 1 %}
-{# Limit CPU usage to avoid triggering a HostHighCpuLoad alert #}
-CPUQuota=50%
-{% endif %}
-- 
GitLab