Skip to content

Commit 481cac8

Browse files
committed
Add user flag for decision
1 parent c35ca7c commit 481cac8

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ borg_user: "root"
5454
borg_group: "root"
5555
backup_user_info:
5656
home: "/home/{{ borg_user }}"
57+
borgmatic_run_as_root: false
5758
...

meta/argument_specs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,7 @@ argument_specs:
232232
type: str
233233
required: false
234234
description: Comment added to the SSH public key.
235+
borgmatic_run_as_root:
236+
type: bool
237+
required: false
238+
description: If the variable is set, systemd will run borgmatic using sudo.

templates/borgmatic.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ConditionACPower=true
1212
[Service]
1313
Type=oneshot
1414
User={{ borg_user }}
15-
ExecStart={{ 'sudo ' if borg_user != 'root'}}borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} {{ borgmatic_timer_flags }}
15+
ExecStart={{ 'sudo ' if borgmatic_run_as_root}}borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} {{ borgmatic_timer_flags }}
1616

1717
# Source: https://projects.torsion.org/borgmatic-collective/borgmatic/raw/branch/master/sample/systemd/borgmatic.service
1818
# Security settings for systemd running as root, optional but recommended to improve security. You

0 commit comments

Comments
 (0)