Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept none as valid init_style #399

Merged
merged 3 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions manifests/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
# [*extract_command*]
# Custom command passed to the archive resource to extract the downloaded archive.
#
# [*init_style*]
# Service startup scripts style (e.g. rc, upstart or systemd).
# Can also be set to `'none'` when you don't want the class to create a startup script/unit_file for you.
# Typically this can be used when a package is already providing the file.
define prometheus::daemon (
String $version,
Prometheus::Uri $real_download_url,
Expand All @@ -78,7 +82,7 @@
Boolean $manage_group = true,
Boolean $purge = true,
String $options = '',
String $init_style = $prometheus::init_style,
Prometheus::Initstyle $init_style = $prometheus::init_style,
String $service_ensure = 'running',
Boolean $service_enable = true,
Boolean $manage_service = true,
Expand Down Expand Up @@ -166,8 +170,8 @@
}


case $init_style {
'upstart' : {
case $init_style { # lint:ignore:case_without_default
'upstart': {
file { "/etc/init/${name}.conf":
mode => '0444',
owner => 'root',
Expand All @@ -183,15 +187,15 @@
mode => '0755',
}
}
'systemd' : {
'systemd': {
include 'systemd'
systemd::unit_file {"${name}.service":
content => template('prometheus/daemon.systemd.erb'),
notify => $notify_service,
}
}
# service_provider returns redhat on CentOS using sysv, https://tickets.puppetlabs.com/browse/PUP-5296
'sysv','redhat' : {
'sysv','redhat': {
file { "/etc/init.d/${name}":
mode => '0555',
owner => 'root',
Expand All @@ -200,7 +204,7 @@
notify => $notify_service,
}
}
'debian' : {
'debian': {
file { "/etc/init.d/${name}":
mode => '0555',
owner => 'root',
Expand All @@ -209,7 +213,7 @@
notify => $notify_service,
}
}
'sles' : {
'sles': {
file { "/etc/init.d/${name}":
mode => '0555',
owner => 'root',
Expand All @@ -218,7 +222,7 @@
notify => $notify_service,
}
}
'launchd' : {
'launchd': {
file { "/Library/LaunchDaemons/io.${name}.daemon.plist":
mode => '0644',
owner => 'root',
Expand All @@ -227,9 +231,7 @@
notify => $notify_service,
}
}
default : {
fail("I don't know how to create an init script for style ${init_style}")
}
'none': {}
}

if $env_file_path != undef {
Expand All @@ -250,10 +252,11 @@
$real_provider = $init_style ? {
'sles' => 'redhat', # mimics puppet's default behaviour
'sysv' => 'redhat', # all currently used cases for 'sysv' are redhat-compatible
'none' => undef,
default => $init_style,
}

if $manage_service == true {
if $manage_service {
service { $name:
ensure => $service_ensure,
name => $init_selector,
Expand Down
10 changes: 10 additions & 0 deletions types/initstyle.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type Prometheus::Initstyle = Enum[
'sysv',
'redhat',
'systemd',
'sles',
'debian',
'launchd',
'upstart',
'none',
]