Add options to set DynamicUser and StateDirectory
Make sure those options are only set if systemd >= 235, since they were introduced in that version. Change-Id: I51f133931a73d648604b5166a7c09da6ffd4c178 Related-Bug: 1805847
This commit is contained in:
parent
79e6cdb138
commit
d11744b1ef
|
@ -102,6 +102,8 @@ systemd_environment: {}
|
|||
# `state` -- (optional) Set the running state of the service.
|
||||
# `environment` -- (optional) set additional environment settings, this option is a hash of strings.
|
||||
# `environment_file` -- (optional) set additional environment settings through a given file. this option is a string.
|
||||
# `dynamic_user` -- (optional) Dynamically set a UNIX user and group when the unit is started; only works if systemd >= 235.
|
||||
# `state_directory` -- (optional) Relative path the state directory; only works if systemd >= 235.
|
||||
|
||||
# Under the service dictionary the "timer" key can be added which will enable a given service
|
||||
# as a timer (Legacy cron job).
|
||||
|
|
|
@ -16,6 +16,10 @@ Type={{ service_type }}
|
|||
User={{ item.systemd_user_name | default(systemd_user_name) }}
|
||||
Group={{ item.systemd_group_name | default(systemd_group_name) }}
|
||||
|
||||
{% if systemd_version|int >= 235 and item.dynamic_user is defined %}
|
||||
DynamicUser={{ item.dynamic_user|bool }}
|
||||
{% endif %}
|
||||
|
||||
{% for key, value in (item.environment | default(systemd_environment)).items() %}
|
||||
Environment="{{ key }}={{ value }}"
|
||||
{% endfor %}
|
||||
|
@ -90,6 +94,9 @@ PrivateNetwork={{ systemd_PrivateNetwork }}
|
|||
PrivateUsers={{ systemd_PrivateUsers }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if systemd_version|int >= 235 and item.state_directory is defined %}
|
||||
StateDirectory={{ item.state_directory }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
[Install]
|
||||
|
|
Loading…
Reference in New Issue