diff --git a/manifests/config.pp b/manifests/config.pp index de76226..865df21 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -64,11 +64,13 @@ $repeaterProtocol = $statsd::repeaterProtocol, $config = $statsd::config, - $env_append = $statsd::env_append, - $nodejs_bin = $statsd::nodejs_bin, - $npm_bin = $statsd::npm_bin, - $statsjs = "${statsd::node_module_dir}/statsd/stats.js", - $logfile = $statsd::logfile, + $env_append = $statsd::env_append, + $nodejs_bin = $statsd::nodejs_bin, + $npm_bin = $statsd::npm_bin, + $statsjs = "${statsd::node_module_dir}/statsd/stats.js", + $logfile = $statsd::logfile, + $init_provider = $statsd::init_provider, + $init_sysconfig = $statsd::init_sysconfig ) { file { '/etc/statsd': @@ -84,11 +86,23 @@ group => 'root', } + exec { 'statsd-systemctl-reload': + command => 'systemctl daemon-reload', + path => $::path, + refreshonly => true, + } + + $_notify = $init_provider ? { + /systemd/ => 'Exec[statsd-systemctl-reload]', + default => undef + } + file { $statsd::init_location: - source => $statsd::init_script, - mode => $statsd::init_mode, - owner => 'root', - group => 'root', + content => template($statsd::init_script), + mode => $statsd::init_mode, + owner => 'root', + group => 'root', + notify => $_notify } file { $statsd::init_sysconfig: diff --git a/manifests/params.pp b/manifests/params.pp index 630fd28..e92953f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -96,7 +96,7 @@ $init_sysconfig = '/etc/sysconfig/statsd' $init_mode = '0755' $init_provider = 'redhat' - $init_script = 'puppet:///modules/statsd/statsd-init-rhel' + $init_script = 'statsd/statsd-init-rhel.erb' } 'Debian': { if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemmajrelease, '16') < 0 { @@ -104,13 +104,13 @@ $init_sysconfig = '/etc/default/statsd' $init_mode = '0644' $init_provider = 'upstart' - $init_script = 'puppet:///modules/statsd/statsd-upstart' + $init_script = 'statsd/statsd-upstart.erb' } else { $init_location = '/lib/systemd/system/statsd.service' $init_sysconfig = '/etc/default/statsd' $init_mode = '0644' $init_provider = 'systemd' - $init_script = 'puppet:///modules/statsd/statsd-systemd' + $init_script = 'statsd/statsd-systemd.erb' } } default: { diff --git a/files/statsd-init-rhel b/templates/statsd-init-rhel.erb similarity index 100% rename from files/statsd-init-rhel rename to templates/statsd-init-rhel.erb diff --git a/files/statsd-systemd b/templates/statsd-systemd.erb similarity index 54% rename from files/statsd-systemd rename to templates/statsd-systemd.erb index 5cef74d..d3e0b2c 100644 --- a/files/statsd-systemd +++ b/templates/statsd-systemd.erb @@ -5,7 +5,12 @@ Wants=network.target [Service] Type=simple -ExecStart=/usr/bin/nodejs /usr/local/lib/node_modules/statsd/stats.js /etc/statsd/localConfig.js +EnvironmentFile=<%= @init_sysconfig %> +<%- + env_string = "" + @env_append.each { |x| env_string << "#{x} -- " } +-%> +ExecStart=<%= env_string %><%= @nodejs_bin %> $STATSJS $STATSD_CONFIG Restart=on-failure RestartSec=10 diff --git a/files/statsd-upstart b/templates/statsd-upstart.erb similarity index 100% rename from files/statsd-upstart rename to templates/statsd-upstart.erb