From 9cf1318cb4986ebfa698350e94c0e63af5a1f1c8 Mon Sep 17 00:00:00 2001 From: Jake Yip Date: Fri, 11 Jun 2021 12:37:47 +1000 Subject: [PATCH] Add syslog_facility parameter to docker::run It is useful to be able to control the facility of log messages, so that it can be handled by syslog appropriately --- manifests/run.pp | 3 +++ spec/defines/run_spec.rb | 3 +++ templates/etc/systemd/system/docker-run.erb | 3 +++ 3 files changed, 9 insertions(+) diff --git a/manifests/run.pp b/manifests/run.pp index 3c0c67e0..7c6408d2 100644 --- a/manifests/run.pp +++ b/manifests/run.pp @@ -187,6 +187,8 @@ # # @param syslog_identifier # +# @param syslog_facility +# # @param read_only # define docker::run( @@ -244,6 +246,7 @@ Optional[Boolean] $remove_volume_on_stop = false, Optional[Integer] $stop_wait_time = 0, Optional[String] $syslog_identifier = undef, + Optional[String] $syslog_facility = undef, Optional[Boolean] $read_only = false, Optional[String] $health_check_cmd = undef, Optional[Boolean] $restart_on_unhealthy = false, diff --git a/spec/defines/run_spec.rb b/spec/defines/run_spec.rb index 62c7d9ef..fec46d58 100644 --- a/spec/defines/run_spec.rb +++ b/spec/defines/run_spec.rb @@ -197,6 +197,9 @@ 'docker_service' => 'my-docker', 'restart_service_on_docker_refresh' => false, }, + 'when passing syslog_facility' => { + 'syslog_facility' => 'user', + }, } describe 'docker::run', type: :define do diff --git a/templates/etc/systemd/system/docker-run.erb b/templates/etc/systemd/system/docker-run.erb index 3286704b..85586f35 100644 --- a/templates/etc/systemd/system/docker-run.erb +++ b/templates/etc/systemd/system/docker-run.erb @@ -32,6 +32,9 @@ Environment="HOME=/root" <%- if @_syslog_identifier -%> SyslogIdentifier=<%= @_syslog_identifier %> <%- end -%> +<%- if @syslog_facility -%> +SyslogFacility=<%= @syslog_facility %> +<%- end -%> ExecStart=/usr/local/bin/docker-run-<%= @sanitised_title %>-start.sh ExecStop=-/usr/local/bin/docker-run-<%= @sanitised_title %>-stop.sh <%- if @remain_after_exit %>