Skip to content

Commit

Permalink
(choria-io#208) improve disabling the server
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <rip@devco.net>
  • Loading branch information
ripienaar committed Dec 28, 2020
1 parent 6db63e1 commit 8df5b25
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 101 deletions.
10 changes: 8 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@
group => $choria::config_group,
mode => "0640",
content => choria::hash2config($config),
notify => Class["choria::service"],
require => Class["choria::install"]
}

if $choria::server {
File[$choria::server_config_file] ~> Class["choria::service"]
}
}

if $choria::server_provisioning_token {
Expand All @@ -126,9 +129,12 @@
group => $choria::config_group,
mode => "0640",
content => $choria::server_provisioning_token,
notify => Class["choria::service"],
require => Class["choria::install"],
}

if $choria::server {
File[$choria::server_config_file] ~> Class["choria::service"]
}
}
}

18 changes: 16 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,24 @@
class{"choria::install": }
-> class{"choria::config": }
-> class{"choria::scout_checks": }
-> class{"choria::service": }

# We use a different class to disable choria service than enable it
# to help the discovery system find machines where the service is actually
# running vs those with it off - it searches on all machines with class
# choria::service so this facilitates client oly installs by setting server false
if $server {
class{"choria::service":
require => Class["choria::scout_checks"]
}
contain choria::service
} else {
class{"choria::service_disable":
require => Class["choria::scout_checks"]
}
contain choria::service_disable
}

contain choria::install
contain choria::scout_checks
contain choria::scout_metrics
contain choria::service
}
17 changes: 3 additions & 14 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,16 @@
if $choria::server {
service{$choria::server_service_name:
ensure => "running",
enable => true
enable => true,
}

# Since the installation of mcollective plugins are handled in another module at
# the moment we have to do this ugly hackery here to ensure we restart choria
# service when new plugins are installed
#
# Eventually this module will own installation of plugins and things will improve
# for now its a bit meh
Service<| title == "mcollective" |> ~> Service[$choria::server_service_name]
# Ensures that module plugin changes will restart choria
Mcollective::Module_plugin <| |> ~> Service[$choria::server_service_name]

# Without this when a mcollective plugin is removed if purge is on the service
# would not be restarted, unfortunate side effect that a client uninstall will
# also yield a restart
File<| tag == "mcollective::plugin_dirs" |> ~> Service[$choria::server_service_name]

} else {
service{$choria::server_service_name:
ensure => "stopped",
enable => false
}
}
}
}
16 changes: 16 additions & 0 deletions manifests/service_disable.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Manages the `choria-server` service
#
# @private
class choria::service_disable {
assert_private()

if $choria::manage_service {
if !$choria::server {
service{$choria::server_service_name:
ensure => "stopped",
enable => false
}
}
}
}

2 changes: 1 addition & 1 deletion spec/classes/broker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe 'choria' do

let :node do
'rspec.puppet.com'
"rspec.puppet.com"
end

on_supported_os.each do |os, facts|
Expand Down
Loading

0 comments on commit 8df5b25

Please sign in to comment.