diff --git a/defaults/main.yml b/defaults/main.yml index 8dda35b..6250012 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -129,7 +129,8 @@ systemd_environment: {} # `before_targets` -- (optional) Start the socket before this list of dependency units. # `bind_targets` -- (optional) Bind the socket to this dependency unit. # `enabled` -- (optional) Set the enabled state of the socket. -# `options` -- (optional) Additional options, like `ListenStream` or other +# `options` -- (optional) Additional options, like `ListenStream` or other. Specifying ListenStream in +# the options will suppress the default 'Service' field in [Socket]. # `state` -- (optional) Set the running state of the socket. # Under the service dictionary the "timer" key can be added which will enable a given service diff --git a/templates/systemd-socket.j2 b/templates/systemd-socket.j2 index a3206e2..3366fbe 100644 --- a/templates/systemd-socket.j2 +++ b/templates/systemd-socket.j2 @@ -13,7 +13,10 @@ BindsTo={{ target }} {% endfor %} [Socket] +{% if 'ListenStream' not in item.1.options %} Service={{ item.0.service_name | replace(' ', '_') }}.service +{% endif %} + {% for key, var in item.1.options.items() | default({}) %} {{ key }}={{ var }} {% endfor %}