From 1013a1526ef7cd0a2d1b57e7120fe590c9b8597f Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Thu, 27 Jan 2022 10:15:46 +0000 Subject: [PATCH] Allow StandardOutput to be set for a systemd service See https://www.freedesktop.org/software/systemd/man/systemd.exec.html Change-Id: I64470b53f5177e9a4e450beaa474036e44705349 --- defaults/main.yml | 1 + templates/systemd-service.j2 | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index 8c2fc3a..a5ef5a1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -126,6 +126,7 @@ systemd_environment: {} # `systemd_run_dir` -- (optional) Run directory that will be used for service runtime. Service slice or name is added to the path # `systemd_lock_dir` -- (optional) Lock directory that will be used for service runtime. Service slice or name is added to the path # `load` -- (optional) Boolean to set if the service is loaded. Socket activated services with '@' may not need to be loaded. +# `standard_output` -- (optional) Set the stdout of the service to go to a non default destination, such as 'socket' # Under the service dictionary the "sockets" key can be added, which may contain list of the sockets # for the given service_name. Each socket in the lsit may have following structure: diff --git a/templates/systemd-service.j2 b/templates/systemd-service.j2 index e6ef303..83abd1e 100644 --- a/templates/systemd-service.j2 +++ b/templates/systemd-service.j2 @@ -63,6 +63,10 @@ Restart={{ systemd_Restart }} RestartSec={{ systemd_RestartSec }} {% endif %} +{% if item.standard_output is defined %} +StandardOutput={{ item.standard_output }} +{% endif %} + # This creates a specific slice which all services will operate from # The accounting options give us the ability to see resource usage through # the `systemd-cgtop` command.