Skip to content

Commit fcffa8d

Browse files
committed
(#64) Allow service to be configured for non-Windows.
Check the service state rather than PID for non-Windows This allows for the continued checking of 'puppet' service but also allows checking other service names like 'puppet-run.service' used by The Foreman module for Puppet. This change is backwards incompatible due to the change in configuration key Fixes #64
1 parent 3178e2a commit fcffa8d

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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:
7373
If you supply the value *none* to *type_whitelist* it will have the effect of denying
7474
all 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
7777
service is running. The service name varies between Puppet open source and
7878
Puppet Enterprise (puppet vs. pe-puppet); the default is puppet, but it can be
7979
explicitly specified:
8080

8181
```yaml
8282
mcollective_agent_puppet::config:
83-
windows_service: puppet
83+
service: puppet
8484
```
8585

8686
The agent will by default invoke `command` to initiate a

agent/puppet.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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)

util/puppet_agent_mgr/mgr_v3.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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).newservice(name: @puppet_service)
64+
status = service.provider.status
65+
status.to_s == 'running'
66+
end
67+
6168
private
6269

6370
def platform_applying?

0 commit comments

Comments
 (0)