From bec4f1acc7a7399cc1cee5f890148f5cd462fd29 Mon Sep 17 00:00:00 2001 From: Mihmet Akpinar Date: Tue, 13 Feb 2024 10:58:20 +0100 Subject: [PATCH] Allow User to add additonal systemd options to instances --- manifests/server/instances.pp | 8 +++++--- templates/ssh_instance_service.erb | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/manifests/server/instances.pp b/manifests/server/instances.pp index 90433dc3..901f5449 100644 --- a/manifests/server/instances.pp +++ b/manifests/server/instances.pp @@ -37,9 +37,11 @@ ) { include ssh::server - $sshd_instance_config = assert_type(Hash, pick($options['sshd_config'], {})) - $sshd_instance_matchblocks = assert_type(Hash, pick($options['match_blocks'], {})) - $sshd_service_options = $options['sshd_service_options'] + $sshd_instance_config = assert_type(Hash, pick($options['sshd_config'], {})) + $sshd_instance_matchblocks = assert_type(Hash, pick($options['match_blocks'], {})) + $sshd_service_options = $options['sshd_service_options'] + $sshd_additional_service_options = $options['sshd_additional_service_options'] + #check if server is a linux if $facts['kernel'] == 'Linux' { case $validate_config_file { diff --git a/templates/ssh_instance_service.erb b/templates/ssh_instance_service.erb index 283a8116..f59164f6 100644 --- a/templates/ssh_instance_service.erb +++ b/templates/ssh_instance_service.erb @@ -9,6 +9,19 @@ After=network.target sshd-keygen.service Wants=sshd-keygen.service [Service] +<%- if @sshd_additional_service_options -%> +<%- @sshd_additional_service_options.each do |k,v| -%> +<%- if v.is_a?(Array) -%> +<%- v.each do |a| -%> +<%- if a != '' && a != nil -%> +<%= k %>=<%= bool2str(a) %> +<%- end -%> +<%- end -%> +<%- elsif v != '' && v != nil -%> +<%= k %>=<%= bool2str(v) %> +<%- end -%> +<%- end -%> +<%- end -%> <% if @sshd_environments_file %> EnvironmentFile=<%= @sshd_environments_file -%> <% end %>