Skip to content

Commit 94506db

Browse files
author
Taylan Develioglu
committed
Decouple managing service and init system from eachother.
Previously the logic didn't make sense, where one could pass a bool to the parameter `init_style` that expects a string to toggle the management of service files in the init system and it was impossible to let the module manage the service but not the init system. This breaks the common case of where you want to let a package prep the init system but still let the module manage the service. This commit decouples the service resource from management of the init system so it offers the choice of using the module-supplied init files. It adds a new parameter to the public class `manage_init` that allows fully shutting down management of the init system so the module can cover all use cases.
1 parent 7b25b15 commit 94506db

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

manifests/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$purge = true,
1616
) {
1717

18-
if $::consul::init_style {
18+
if $::consul::manage_init {
1919

2020
case $::consul::init_style {
2121
'upstart': {

manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
$install_method = $::consul::params::install_method,
162162
$join_wan = $::consul::params::join_wan,
163163
$manage_group = $::consul::params::manage_group,
164+
$manage_init = $::consul::params::manage_init,
164165
$manage_service = $::consul::params::manage_service,
165166
$manage_user = $::consul::params::manage_user,
166167
$os = $::consul::params::os,
@@ -201,6 +202,7 @@
201202
validate_hash($watches)
202203
validate_hash($checks)
203204
validate_hash($acls)
205+
validate_bool($manage_init)
204206

205207
$config_hash_real = deep_merge($config_defaults, $config_hash)
206208

manifests/params.pp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
$group = 'consul'
2121
$install_method = 'url'
2222
$join_wan = false
23+
$manage_init = true
2324
$manage_group = true
2425
$manage_service = true
2526
$manage_user = true
@@ -93,9 +94,6 @@
9394
} elsif $::operatingsystem == 'Amazon' {
9495
$init_style = 'init'
9596
} else {
96-
$init_style = undef
97-
}
98-
if $init_style == undef {
99-
fail('Unsupported OS')
97+
fail('Cannot determine init_style, unsupported OS')
10098
}
10199
}

manifests/run_service.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
default => 'consul',
1111
}
1212

13-
if $::consul::manage_service == true and $::consul::init_style {
13+
if $::consul::manage_service == true {
1414
service { 'consul':
1515
ensure => $::consul::service_ensure,
1616
name => $init_selector,

spec/classes/init_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,9 @@
694694
it { should contain_file('/lib/systemd/system/consul.service').with_content(/consul agent/) }
695695
end
696696

697-
context "When asked not to manage the init_style" do
698-
let(:params) {{ :init_style => false }}
699-
it { should contain_class('consul').with_init_style(false) }
697+
context "When asked not to manage the init system" do
698+
let(:params) {{ :manage_init => false }}
699+
it { should contain_class('consul').with_manage_init(false) }
700700
it { should_not contain_file("/etc/init.d/consul") }
701701
it { should_not contain_file("/lib/systemd/system/consul.service") }
702702
end

0 commit comments

Comments
 (0)