Skip to content

Commit 965dbcf

Browse files
authored
Merge pull request vlcty#9 from stuehmer/patch-1
Avoid setting User attribute in 'user' scope
2 parents df7e1ae + 719bf1b commit 965dbcf

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ timers:
2323

2424
That's all the magic.
2525

26-
### Existing variables
26+
### Existing variables per timer
2727

2828
| Variable | Required | Default value / Explanation |
2929
|----------|----------|------------------------------|
@@ -58,6 +58,24 @@ More about timers: https://www.freedesktop.org/software/systemd/man/systemd.time
5858

5959
More about timespans: https://www.freedesktop.org/software/systemd/man/systemd.time.html
6060

61+
### Existing variables globally, for the role
62+
| Variable | Required | Default value / Explanation |
63+
|----------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
64+
| systemd_scope | no | Create system or user units. Default: `system`. |
65+
| systemd_base_path | no | Where to generate the systemd unit files. Set this to e.g. `~/.config/systemd/user` when using *systemd_scope*=`user`. Default: `/etc/systemd/system`. |
66+
67+
You can create user timers for non-root services in combination with `become_user: '{{ my_user }}'`. Example:
68+
```
69+
systemd_base_path: ~/.config/systemd/user
70+
systemd_scope: user
71+
timers:
72+
timer-one:
73+
timer_command: ...
74+
timer_OnCalendar: ...
75+
timer_user: '{{ my_user }}'
76+
...
77+
```
78+
6179
## Working with shell redirection
6280

6381
Shell redirection does not work out of the box. You have to work around that by calling `sh` or `bash`.

templates/service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ EnvironmentFile={{ item.value.timer_envfile }}
1414
ExecStartPre={{ item.value.timer_precommand }}
1515
{% endif %}
1616
ExecStart={{ item.value.timer_command }}
17-
{% if item.value.timer_user is defined %}
17+
{% if item.value.timer_user is defined and (systemd_scope is not defined or systemd_scope != 'user') %}
1818
User={{ item.value.timer_user }}
1919
{% endif %}
2020
{% if item.value.timer_workingdir is defined %}

0 commit comments

Comments
 (0)