From 8503103a99ba8ac5de1c6961e116914a4acdb001 Mon Sep 17 00:00:00 2001 From: Tim Birkett Date: Tue, 18 Jul 2017 13:34:49 +0100 Subject: [PATCH] refactor / add config_change_restart option --- manifests/instance.pp | 41 +++++++++++++++--------- templates/service/dropwizard.systemd.erb | 1 - 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/manifests/instance.pp b/manifests/instance.pp index 6347c50..853ee55 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -1,19 +1,20 @@ # Define: dropwizard::instance define dropwizard::instance ( - $ensure = 'present', - $version = '0.0.1-SNAPSHOT', - $package = undef, - $jar_file = undef, - $sysconfig = {}, - $user = $::dropwizard::run_user, - $group = $::dropwizard::run_group, - $mode = $::dropwizard::config_mode, - $base_path = $::dropwizard::base_path, - $sysconfig_path = $::dropwizard::sysconfig_path, - $config_path = $::dropwizard::config_path, - $config_test = false, - $config_files = [], - $config_hash = { + $ensure = 'present', + $version = '0.0.1-SNAPSHOT', + $package = undef, + $jar_file = undef, + $sysconfig = {}, + $user = $::dropwizard::run_user, + $group = $::dropwizard::run_group, + $mode = $::dropwizard::config_mode, + $base_path = $::dropwizard::base_path, + $sysconfig_path = $::dropwizard::sysconfig_path, + $config_path = $::dropwizard::config_path, + $config_test = false, + $config_change_restart = true, + $config_files = [], + $config_hash = { 'server' => { 'type' => 'simple', 'appContextPath' => '/application', @@ -47,9 +48,17 @@ default => 'present', } - #Set validate_cmd + # Set validate_cmd if $config_test { $validate_cmd = "su - ${user} -c \"/bin/java -jar ${jar_file} check %\"" + } else { + $validate_cmd = undef + } + + if $config_change_restart { + $notify_service = Service["dropwizard_${name}"] + } else { + $notify_service = undef } file { "${sysconfig_path}/dropwizard_${name}": @@ -69,7 +78,7 @@ content => inline_template('<%= @config_hash.to_yaml.gsub("---\n", "") %>'), require => File[$config_path,"${sysconfig_path}/dropwizard_${name}"], validate_cmd => $validate_cmd, - notify => Service["dropwizard_${name}"], + notify => $notify_service, } # Assign default jar diff --git a/templates/service/dropwizard.systemd.erb b/templates/service/dropwizard.systemd.erb index 8c0e3e4..68175d2 100644 --- a/templates/service/dropwizard.systemd.erb +++ b/templates/service/dropwizard.systemd.erb @@ -13,4 +13,3 @@ RestartSec=30s [Install] WantedBy=multi-user.target -