Skip to content

Commit 9a2c027

Browse files
committed
Add user flag for decision
1 parent af10c33 commit 9a2c027

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ borg_user: "root"
5050
borg_group: "root"
5151
backup_user_info:
5252
home: "/home/{{ borg_user }}"
53+
borgmatic_run_as_root: false
5354
...

meta/argument_specs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,7 @@ argument_specs:
203203
type: str
204204
required: false
205205
description: Comment added to the SSH public key.
206+
borgmatic_run_as_root:
207+
type: bool
208+
required: false
209+
description: If the variable is set, systemd will run borgmatic using sudo.

templates/borgmatic.service.j2

Lines changed: 2 additions & 2 deletions
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
@@ -22,7 +22,7 @@ LockPersonality=true
2222
# Certain borgmatic features like Healthchecks integration need MemoryDenyWriteExecute to be off.
2323
# But you can try setting it to "yes" for improved security if you don't use those features.
2424
MemoryDenyWriteExecute=no
25-
NoNewPrivileges={{ 'no' if borg_user != 'root' else 'yes'}}
25+
NoNewPrivileges={{ 'no' if borgmatic_run_as_root else 'yes'}}
2626
PrivateDevices=yes
2727
PrivateTmp=yes
2828
ProtectClock=yes

0 commit comments

Comments
 (0)