Skip to content

Commit aa44489

Browse files
author
Fabian Hausmann
committed
Add user flag for decision
1 parent 323ab2d commit aa44489

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ borg_user: "root"
4848
borg_group: "root"
4949
backup_user_info:
5050
home: "/home/{{ borg_user }}"
51+
borgmatic_run_as_root: false
5152
...

meta/argument_specs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,7 @@ argument_specs:
192192
type: str
193193
required: false
194194
description: Name of the SSH public and private key
195+
borgmatic_run_as_root:
196+
type: bool
197+
required: false
198+
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 }}
15+
ExecStart={{ 'sudo ' if borgmatic_run_as_root}}borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}
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)