File tree Expand file tree Collapse file tree 5 files changed +23
-11
lines changed
Expand file tree Collapse file tree 5 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ mcollective_agent_puppet::config:
3737 command : " puppet agent"
3838 splay : true
3939 splaylimit : 30
40- windows_service : puppet
40+ service : puppet
4141 signal_daemon : true
4242` ` `
4343
@@ -73,14 +73,14 @@ mcollective_agent_puppet::config:
7373If you supply the value *none* to *type_whitelist* it will have the effect of denying
7474all resource management - this is the default.
7575
76- On Windows, the name of the Puppet service is needed to determine if the
76+ The name of the Puppet service is needed to determine if the
7777service is running. The service name varies between Puppet open source and
7878Puppet Enterprise (puppet vs. pe-puppet); the default is puppet, but it can be
7979explicitly specified :
8080
8181` ` ` yaml
8282mcollective_agent_puppet::config:
83- windows_service : puppet
83+ service : puppet
8484` ` `
8585
8686The agent will by default invoke `command` to initiate a
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ def startup_hook
1010 configfile = @config . pluginconf . fetch ( "puppet.config" , nil )
1111
1212 @puppet_command = @config . pluginconf . fetch ( "puppet.command" , default_agent_command )
13- @puppet_service = @config . pluginconf . fetch ( "puppet.windows_service " , "puppet" )
13+ @puppet_service = @config . pluginconf . fetch ( "puppet.service " , "puppet" )
1414 @puppet_splaylimit = Integer ( @config . pluginconf . fetch ( "puppet.splaylimit" , 30 ) )
1515 @puppet_splay = Util . str_to_bool ( @config . pluginconf . fetch ( "puppet.splay" , "true" ) )
1616 @puppet_agent = Util ::PuppetAgentMgr . manager ( configfile , @puppet_service )
Original file line number Diff line number Diff line change 2727
2828 it "should set the service name based on the config" do
2929 MCollective ::Config . instance . stubs ( :pluginconf ) . returns (
30- { "puppet.windows_service " => "not-puppet" } )
30+ { "puppet.service " => "not-puppet" } )
3131 MCollective ::Util ::PuppetAgentMgr . expects ( :manager ) . with ( nil , "not-puppet" )
3232
3333 @agent . startup_hook
Original file line number Diff line number Diff line change @@ -15,15 +15,20 @@ module MCollective::Util
1515 end
1616
1717 describe "#daemon_present?" do
18- it "should return false if the pidfile does not exist" do
19- File . expects ( :exist? ) . with ( "pidfile" ) . returns ( false )
18+ before :each do
19+ @type = mock ; @service = mock ; @provider = mock
20+ @service . stubs ( :provider ) . returns ( @provider )
21+ @type . stubs ( :new ) . returns ( @service )
22+ Puppet ::Type . stubs ( :type ) . returns ( @type )
23+ end
24+
25+ it "should return false if the service is not running" do
26+ @provider . stubs ( :status ) . returns ( :stopped )
2027 @manager . daemon_present? . should == false
2128 end
2229
23- it "should check the pid if the pidfile exist" do
24- File . expects ( :exist? ) . with ( "pidfile" ) . returns ( true )
25- File . expects ( :read ) . with ( "pidfile" ) . returns ( 1 )
26- @manager . expects ( :has_process_for_pid? ) . with ( 1 ) . returns ( true )
30+ it "should return true if the service is running" do
31+ @provider . stubs ( :status ) . returns ( :running )
2732 @manager . daemon_present? . should == true
2833 end
2934 end
Original file line number Diff line number Diff line change @@ -58,6 +58,13 @@ def disabled?
5858 File . exist? ( Puppet [ :agent_disabled_lockfile ] )
5959 end
6060
61+ # is the agent daemon currently running?
62+ def daemon_present?
63+ service = ::Puppet ::Type . type ( :service ) . new ( name : @puppet_service )
64+ status = service . provider . status
65+ status . to_s == 'running'
66+ end
67+
6168 private
6269
6370 def platform_applying?
You can’t perform that action at this time.
0 commit comments