Filippo Giunchedi has uploaded a new change for review. https://gerrit.wikimedia.org/r/284871
Change subject: statsite: port to jessie/systemd ...................................................................... statsite: port to jessie/systemd Change-Id: I0dd91cf19339229fda3a723f8ce730ee5e37ccf4 --- M manifests/role/statsd.pp M modules/statsite/manifests/decommission.pp M modules/statsite/manifests/init.pp M modules/statsite/manifests/instance.pp A modules/statsite/templates/initscripts/statsite-instances.systemd.erb A modules/statsite/templates/initscripts/[email protected] 6 files changed, 74 insertions(+), 27 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/71/284871/1 diff --git a/manifests/role/statsd.pp b/manifests/role/statsd.pp index 349e121..5497b99 100644 --- a/manifests/role/statsd.pp +++ b/manifests/role/statsd.pp @@ -59,10 +59,12 @@ input_counter => "statsd.${::hostname}-8131.received", } - nrpe::monitor_service { 'statsite_backends': - description => 'statsite backend instances', - nrpe_command => '/sbin/statsitectl check', - require => Service['statsite'], + if $::initsystem == 'upstart' { + nrpe::monitor_service { 'statsite_backends': + description => 'statsite backend instances', + nrpe_command => '/sbin/statsitectl check', + require => Service['statsite'], + } } diamond::collector { 'UDPCollector': } diff --git a/modules/statsite/manifests/decommission.pp b/modules/statsite/manifests/decommission.pp index 8a75e06..1cace69 100644 --- a/modules/statsite/manifests/decommission.pp +++ b/modules/statsite/manifests/decommission.pp @@ -7,14 +7,14 @@ ensure => purged, } - if os_version('ubuntu >= precise') { - file { '/etc/statsite': - ensure => absent, - recurse => true, - purge => true, - force => true, - } + file { '/etc/statsite': + ensure => absent, + recurse => true, + purge => true, + force => true, + } + if $::initsystem == 'upstart' { file { '/sbin/statsitectl': ensure => absent, } @@ -41,13 +41,6 @@ File['/sbin/statsitectl'], File['/etc/statsite'], File['/etc/init/statsite'] ], - } - } - - if os_version('debian >= jessie') { - service { 'statsite': - ensure => 'stopped', - before => Package['statsite'], } } } diff --git a/modules/statsite/manifests/init.pp b/modules/statsite/manifests/init.pp index a64be98..65a2e67 100644 --- a/modules/statsite/manifests/init.pp +++ b/modules/statsite/manifests/init.pp @@ -32,7 +32,7 @@ mode => '0555', } - if os_version('ubuntu >= precise') { + if $::initsystem == 'upstart' { file { '/sbin/statsitectl': source => 'puppet:///modules/statsite/statsitectl', mode => '0755', @@ -62,10 +62,25 @@ } } - if os_version('debian >= jessie') { - service { 'statsite': - ensure => 'running', - require => Package['statsite'], + if $::initsystem == 'systemd' { + # stop the default service and rely on statsite::instance to do the + # right thing + exec { 'mask_statsite': + command => '/bin/systemctl mask statsite.service', + creates => '/etc/systemd/system/statsite.service', + before => Package['statsite'], + } + + base::service_unit { 'statsite@': + ensure => present, + systemd => true, + declare_service => false, + } + + base::service_unit { 'statsite-instances': + ensure => present, + systemd => true, + declare_service => false, } } } diff --git a/modules/statsite/manifests/instance.pp b/modules/statsite/manifests/instance.pp index e067e8c..2e0eb81 100644 --- a/modules/statsite/manifests/instance.pp +++ b/modules/statsite/manifests/instance.pp @@ -28,7 +28,7 @@ ) { $stream_cmd = "python /usr/lib/statsite/sinks/graphite.py ${graphite_host} ${graphite_port} \"\"" - if os_version('ubuntu >= precise') { + if $::initsystem == 'upstart' { file { "/etc/statsite/${port}.ini": content => template('statsite/statsite.ini.erb'), require => Package['statsite'], @@ -36,11 +36,27 @@ } } - if os_version('debian >= jessie') { - file { '/etc/statsite.ini': + if $::initsystem == 'systemd' { + $instance_service_path = "/lib/systemd/system/statsite@${port}.service" + $template_service_path = '/lib/systemd/system/[email protected]' + + file { $instance_service_path: + ensure => 'link', + target => $template_service_path, + require => File[$template_service_path], + } + + file { "/etc/statsite/${port}.ini": content => template('statsite/statsite.ini.erb'), require => Package['statsite'], - notify => Service['statsite'], + notify => Service["statsite@${port}"], + } + + service { "statsite@${port}": + ensure => 'running', + provider => 'systemd', + enable => true, + require => File[$instance_service_path], } } } diff --git a/modules/statsite/templates/initscripts/statsite-instances.systemd.erb b/modules/statsite/templates/initscripts/statsite-instances.systemd.erb new file mode 100644 index 0000000..a76764d --- /dev/null +++ b/modules/statsite/templates/initscripts/statsite-instances.systemd.erb @@ -0,0 +1,7 @@ +[Unit] +Description=statsite instances + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/bin/true diff --git a/modules/statsite/templates/initscripts/[email protected] b/modules/statsite/templates/initscripts/[email protected] new file mode 100644 index 0000000..405ef15 --- /dev/null +++ b/modules/statsite/templates/initscripts/[email protected] @@ -0,0 +1,14 @@ +[Unit] +Description=statsite (instance %i) +PartOf=statsite-instances.service + +[Service] +User=statsite +ExecStart=/usr/bin/statsite -f /etc/statsite/%i.ini + +[Install] +WantedBy=multi-user.target + +[Journal] +RateLimitInterval=10s +RateLimitBurst=500 -- To view, visit https://gerrit.wikimedia.org/r/284871 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0dd91cf19339229fda3a723f8ce730ee5e37ccf4 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Filippo Giunchedi <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
