microwave 0.1004.4 → 0.1004.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -3
- data/lib/chef/client.rb +2 -11
- data/lib/chef/platform.rb +1 -192
- data/lib/chef/providers.rb +0 -68
- data/lib/chef/resources.rb +0 -36
- data/lib/chef/version.rb +1 -1
- metadata +123 -239
- data/lib/chef/provider/breakpoint.rb +0 -31
- data/lib/chef/provider/cron.rb +0 -186
- data/lib/chef/provider/cron/solaris.rb +0 -195
- data/lib/chef/provider/deploy.rb +0 -343
- data/lib/chef/provider/deploy/revision.rb +0 -80
- data/lib/chef/provider/deploy/timestamped.rb +0 -33
- data/lib/chef/provider/env.rb +0 -152
- data/lib/chef/provider/env/windows.rb +0 -75
- data/lib/chef/provider/erl_call.rb +0 -101
- data/lib/chef/provider/git.rb +0 -243
- data/lib/chef/provider/group.rb +0 -133
- data/lib/chef/provider/group/aix.rb +0 -70
- data/lib/chef/provider/group/dscl.rb +0 -121
- data/lib/chef/provider/group/gpasswd.rb +0 -53
- data/lib/chef/provider/group/groupadd.rb +0 -81
- data/lib/chef/provider/group/pw.rb +0 -84
- data/lib/chef/provider/group/suse.rb +0 -53
- data/lib/chef/provider/group/usermod.rb +0 -57
- data/lib/chef/provider/group/windows.rb +0 -79
- data/lib/chef/provider/ifconfig.rb +0 -134
- data/lib/chef/provider/log.rb +0 -54
- data/lib/chef/provider/mdadm.rb +0 -91
- data/lib/chef/provider/mount.rb +0 -114
- data/lib/chef/provider/mount/mount.rb +0 -240
- data/lib/chef/provider/mount/windows.rb +0 -81
- data/lib/chef/provider/ohai.rb +0 -42
- data/lib/chef/provider/package.rb +0 -163
- data/lib/chef/provider/package/apt.rb +0 -135
- data/lib/chef/provider/package/dpkg.rb +0 -115
- data/lib/chef/provider/package/easy_install.rb +0 -136
- data/lib/chef/provider/package/freebsd.rb +0 -125
- data/lib/chef/provider/package/macports.rb +0 -105
- data/lib/chef/provider/package/pacman.rb +0 -101
- data/lib/chef/provider/package/portage.rb +0 -135
- data/lib/chef/provider/package/rpm.rb +0 -104
- data/lib/chef/provider/package/rubygems.rb +0 -465
- data/lib/chef/provider/package/solaris.rb +0 -130
- data/lib/chef/provider/package/yum.rb +0 -1128
- data/lib/chef/provider/package/zypper.rb +0 -144
- data/lib/chef/provider/route.rb +0 -193
- data/lib/chef/provider/ruby_block.rb +0 -34
- data/lib/chef/provider/script.rb +0 -55
- data/lib/chef/provider/service.rb +0 -122
- data/lib/chef/provider/service/arch.rb +0 -116
- data/lib/chef/provider/service/debian.rb +0 -130
- data/lib/chef/provider/service/freebsd.rb +0 -154
- data/lib/chef/provider/service/gentoo.rb +0 -53
- data/lib/chef/provider/service/init.rb +0 -71
- data/lib/chef/provider/service/insserv.rb +0 -52
- data/lib/chef/provider/service/redhat.rb +0 -60
- data/lib/chef/provider/service/simple.rb +0 -120
- data/lib/chef/provider/service/solaris.rb +0 -85
- data/lib/chef/provider/service/systemd.rb +0 -102
- data/lib/chef/provider/service/upstart.rb +0 -198
- data/lib/chef/provider/service/windows.rb +0 -146
- data/lib/chef/provider/subversion.rb +0 -197
- data/lib/chef/provider/user.rb +0 -186
- data/lib/chef/provider/user/dscl.rb +0 -280
- data/lib/chef/provider/user/pw.rb +0 -113
- data/lib/chef/provider/user/useradd.rb +0 -137
- data/lib/chef/provider/user/windows.rb +0 -124
- data/lib/chef/resource/apt_package.rb +0 -34
- data/lib/chef/resource/bash.rb +0 -33
- data/lib/chef/resource/breakpoint.rb +0 -35
- data/lib/chef/resource/cron.rb +0 -188
- data/lib/chef/resource/csh.rb +0 -33
- data/lib/chef/resource/deploy.rb +0 -380
- data/lib/chef/resource/deploy_revision.rb +0 -40
- data/lib/chef/resource/dpkg_package.rb +0 -34
- data/lib/chef/resource/easy_install_package.rb +0 -57
- data/lib/chef/resource/erl_call.rb +0 -83
- data/lib/chef/resource/freebsd_package.rb +0 -35
- data/lib/chef/resource/gem_package.rb +0 -53
- data/lib/chef/resource/git.rb +0 -46
- data/lib/chef/resource/group.rb +0 -70
- data/lib/chef/resource/ifconfig.rb +0 -134
- data/lib/chef/resource/log.rb +0 -62
- data/lib/chef/resource/macports_package.rb +0 -29
- data/lib/chef/resource/mdadm.rb +0 -82
- data/lib/chef/resource/mount.rb +0 -134
- data/lib/chef/resource/ohai.rb +0 -40
- data/lib/chef/resource/package.rb +0 -80
- data/lib/chef/resource/pacman_package.rb +0 -33
- data/lib/chef/resource/perl.rb +0 -33
- data/lib/chef/resource/portage_package.rb +0 -33
- data/lib/chef/resource/python.rb +0 -33
- data/lib/chef/resource/route.rb +0 -135
- data/lib/chef/resource/rpm_package.rb +0 -34
- data/lib/chef/resource/ruby.rb +0 -33
- data/lib/chef/resource/ruby_block.rb +0 -40
- data/lib/chef/resource/scm.rb +0 -147
- data/lib/chef/resource/script.rb +0 -60
- data/lib/chef/resource/service.rb +0 -160
- data/lib/chef/resource/solaris_package.rb +0 -36
- data/lib/chef/resource/subversion.rb +0 -36
- data/lib/chef/resource/timestamped_deploy.rb +0 -31
- data/lib/chef/resource/user.rb +0 -130
- data/lib/chef/resource/yum_package.rb +0 -63
@@ -1,71 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: AJ Christensen (<aj@hjksolutions.com>)
|
3
|
-
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/service'
|
20
|
-
require 'chef/provider/service/simple'
|
21
|
-
require 'chef/mixin/command'
|
22
|
-
|
23
|
-
class Chef
|
24
|
-
class Provider
|
25
|
-
class Service
|
26
|
-
class Init < Chef::Provider::Service::Simple
|
27
|
-
|
28
|
-
def initialize(new_resource, run_context)
|
29
|
-
super
|
30
|
-
@init_command = "/etc/init.d/#{@new_resource.service_name}"
|
31
|
-
end
|
32
|
-
|
33
|
-
def start_service
|
34
|
-
if @new_resource.start_command
|
35
|
-
super
|
36
|
-
else
|
37
|
-
run_command(:command => "#{@init_command} start")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def stop_service
|
42
|
-
if @new_resource.stop_command
|
43
|
-
super
|
44
|
-
else
|
45
|
-
run_command(:command => "#{@init_command} stop")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def restart_service
|
50
|
-
if @new_resource.restart_command
|
51
|
-
super
|
52
|
-
elsif @new_resource.supports[:restart]
|
53
|
-
run_command(:command => "#{@init_command} restart")
|
54
|
-
else
|
55
|
-
stop_service
|
56
|
-
sleep 1
|
57
|
-
start_service
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def reload_service
|
62
|
-
if @new_resource.reload_command
|
63
|
-
super
|
64
|
-
elsif @new_resource.supports[:reload]
|
65
|
-
run_command(:command => "#{@init_command} reload")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Bryan McLellan <btm@loftninjas.org>
|
3
|
-
# Copyright:: Copyright (c) 2011 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/service'
|
20
|
-
require 'chef/provider/service/init'
|
21
|
-
require 'chef/mixin/command'
|
22
|
-
|
23
|
-
class Chef
|
24
|
-
class Provider
|
25
|
-
class Service
|
26
|
-
class Insserv < Chef::Provider::Service::Init
|
27
|
-
|
28
|
-
def load_current_resource
|
29
|
-
super
|
30
|
-
|
31
|
-
# Look for a /etc/rc.*/SnnSERVICE link to signifiy that the service would be started in a runlevel
|
32
|
-
if Dir.glob("/etc/rc**/S*#{@current_resource.service_name}").empty?
|
33
|
-
@current_resource.enabled false
|
34
|
-
else
|
35
|
-
@current_resource.enabled true
|
36
|
-
end
|
37
|
-
|
38
|
-
@current_resource
|
39
|
-
end
|
40
|
-
|
41
|
-
def enable_service()
|
42
|
-
run_command(:command => "/sbin/insserv -r -f #{@new_resource.service_name}")
|
43
|
-
run_command(:command => "/sbin/insserv -d -f #{@new_resource.service_name}")
|
44
|
-
end
|
45
|
-
|
46
|
-
def disable_service()
|
47
|
-
run_command(:command => "/sbin/insserv -r -f #{@new_resource.service_name}")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: AJ Christensen (<aj@hjksolutions.com>)
|
3
|
-
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/service'
|
20
|
-
require 'chef/provider/service/init'
|
21
|
-
require 'chef/mixin/shell_out'
|
22
|
-
|
23
|
-
class Chef
|
24
|
-
class Provider
|
25
|
-
class Service
|
26
|
-
class Redhat < Chef::Provider::Service::Init
|
27
|
-
include Chef::Mixin::ShellOut
|
28
|
-
|
29
|
-
CHKCONFIG_ON = /\d:on/
|
30
|
-
|
31
|
-
def initialize(new_resource, run_context)
|
32
|
-
super
|
33
|
-
@init_command = "/sbin/service #{@new_resource.service_name}"
|
34
|
-
@new_resource.supports[:status] = true
|
35
|
-
end
|
36
|
-
|
37
|
-
def load_current_resource
|
38
|
-
unless ::File.exists? "/sbin/chkconfig"
|
39
|
-
raise Chef::Exceptions::Service, "/sbin/chkconfig does not exist!"
|
40
|
-
end
|
41
|
-
|
42
|
-
super
|
43
|
-
|
44
|
-
chkconfig = shell_out!("/sbin/chkconfig --list #{@current_resource.service_name}", :returns => [0,1])
|
45
|
-
@current_resource.enabled(!!(chkconfig.stdout =~ CHKCONFIG_ON))
|
46
|
-
@current_resource
|
47
|
-
end
|
48
|
-
|
49
|
-
def enable_service()
|
50
|
-
shell_out! "/sbin/chkconfig #{@new_resource.service_name} on"
|
51
|
-
end
|
52
|
-
|
53
|
-
def disable_service()
|
54
|
-
shell_out! "/sbin/chkconfig #{@new_resource.service_name} off"
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
|
-
# Copyright:: Copyright (c) 2009 Mathieu Sauve-Frankel
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/service'
|
20
|
-
require 'chef/mixin/command'
|
21
|
-
|
22
|
-
class Chef
|
23
|
-
class Provider
|
24
|
-
class Service
|
25
|
-
class Simple < Chef::Provider::Service
|
26
|
-
def load_current_resource
|
27
|
-
@current_resource = Chef::Resource::Service.new(@new_resource.name)
|
28
|
-
@current_resource.service_name(@new_resource.service_name)
|
29
|
-
if @new_resource.status_command
|
30
|
-
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
|
31
|
-
|
32
|
-
begin
|
33
|
-
if run_command(:command => @new_resource.status_command) == 0
|
34
|
-
@current_resource.running true
|
35
|
-
Chef::Log.debug("#{@new_resource} is running")
|
36
|
-
end
|
37
|
-
rescue Chef::Exceptions::Exec
|
38
|
-
@current_resource.running false
|
39
|
-
nil
|
40
|
-
end
|
41
|
-
|
42
|
-
elsif @new_resource.supports[:status]
|
43
|
-
Chef::Log.debug("#{@new_resource} supports status, running")
|
44
|
-
|
45
|
-
begin
|
46
|
-
if run_command(:command => "#{@init_command} status") == 0
|
47
|
-
@current_resource.running true
|
48
|
-
Chef::Log.debug("#{@new_resource} is running")
|
49
|
-
end
|
50
|
-
rescue Chef::Exceptions::Exec
|
51
|
-
@current_resource.running false
|
52
|
-
nil
|
53
|
-
end
|
54
|
-
elsif
|
55
|
-
Chef::Log.debug "#{@new_resource} falling back to process table inspection"
|
56
|
-
if ps_cmd.nil? or ps_cmd.empty?
|
57
|
-
raise Chef::Exceptions::Service, "#{@new_resource} could not determine how to inspect the process table, please set this nodes 'command.ps' attribute"
|
58
|
-
end
|
59
|
-
status = popen4(ps_cmd) do |pid, stdin, stdout, stderr|
|
60
|
-
r = Regexp.new(@new_resource.pattern)
|
61
|
-
Chef::Log.debug "#{@new_resource} attempting to match '#{@new_resource.pattern}' (#{r.inspect}) against process list"
|
62
|
-
stdout.each_line do |line|
|
63
|
-
if r.match(line)
|
64
|
-
@current_resource.running true
|
65
|
-
break
|
66
|
-
end
|
67
|
-
end
|
68
|
-
@current_resource.running false unless @current_resource.running
|
69
|
-
end
|
70
|
-
unless status.exitstatus == 0
|
71
|
-
raise Chef::Exceptions::Service, "Command #{ps_cmd} failed"
|
72
|
-
else
|
73
|
-
Chef::Log.debug "#{@new_resource} running: #{@current_resource.running}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
@current_resource
|
78
|
-
end
|
79
|
-
|
80
|
-
def start_service
|
81
|
-
if @new_resource.start_command
|
82
|
-
run_command(:command => @new_resource.start_command)
|
83
|
-
else
|
84
|
-
raise Chef::Exceptions::Service, "#{self.to_s} requires that start_command to be set"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def stop_service
|
89
|
-
if @new_resource.stop_command
|
90
|
-
run_command(:command => @new_resource.stop_command)
|
91
|
-
else
|
92
|
-
raise Chef::Exceptions::Service, "#{self.to_s} requires that stop_command to be set"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def restart_service
|
97
|
-
if @new_resource.restart_command
|
98
|
-
run_command(:command => @new_resource.restart_command)
|
99
|
-
else
|
100
|
-
stop_service
|
101
|
-
sleep 1
|
102
|
-
start_service
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def reload_service
|
107
|
-
if @new_resource.reload_command
|
108
|
-
run_command(:command => @new_resource.reload_command)
|
109
|
-
else
|
110
|
-
raise Chef::Exceptions::Service, "#{self.to_s} requires that reload_command to be set"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def ps_cmd
|
115
|
-
@run_context.node[:command] && @run_context.node[:command][:ps]
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Toomas Pelberg (<toomasp@gmx.net>)
|
3
|
-
# Copyright:: Copyright (c) 2010 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/service'
|
20
|
-
require 'chef/mixin/command'
|
21
|
-
|
22
|
-
class Chef
|
23
|
-
class Provider
|
24
|
-
class Service
|
25
|
-
class Solaris < Chef::Provider::Service
|
26
|
-
|
27
|
-
def initialize(new_resource, run_context=nil)
|
28
|
-
super
|
29
|
-
@init_command = "/usr/sbin/svcadm"
|
30
|
-
@status_command = "/bin/svcs -l"
|
31
|
-
end
|
32
|
-
|
33
|
-
def load_current_resource
|
34
|
-
@current_resource = Chef::Resource::Service.new(@new_resource.name)
|
35
|
-
@current_resource.service_name(@new_resource.service_name)
|
36
|
-
unless ::File.exists? "/bin/svcs"
|
37
|
-
raise Chef::Exceptions::Service, "/bin/svcs does not exist!"
|
38
|
-
end
|
39
|
-
@status = service_status.enabled
|
40
|
-
@current_resource
|
41
|
-
end
|
42
|
-
|
43
|
-
def enable_service
|
44
|
-
run_command(:command => "#{@init_command} enable #{@new_resource.service_name}")
|
45
|
-
return service_status.enabled
|
46
|
-
end
|
47
|
-
|
48
|
-
def disable_service
|
49
|
-
run_command(:command => "#{@init_command} disable #{@new_resource.service_name}")
|
50
|
-
return service_status.enabled
|
51
|
-
end
|
52
|
-
|
53
|
-
alias_method :stop_service, :disable_service
|
54
|
-
alias_method :start_service, :enable_service
|
55
|
-
|
56
|
-
def reload_service
|
57
|
-
run_command(:command => "#{@init_command} refresh #{@new_resource.service_name}")
|
58
|
-
end
|
59
|
-
|
60
|
-
def restart_service
|
61
|
-
disable_service
|
62
|
-
return enable_service
|
63
|
-
end
|
64
|
-
|
65
|
-
def service_status
|
66
|
-
status = popen4("#{@status_command} #{@current_resource.service_name}") do |pid, stdin, stdout, stderr|
|
67
|
-
stdout.each do |line|
|
68
|
-
case line
|
69
|
-
when /state\s+online/
|
70
|
-
@current_resource.enabled(true)
|
71
|
-
@current_resource.running(true)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
unless @current_resource.enabled
|
76
|
-
@current_resource.enabled(false)
|
77
|
-
@current_resource.running(false)
|
78
|
-
end
|
79
|
-
@current_resource
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Stephen Haynes (<sh@nomitor.com>)
|
3
|
-
# Copyright:: Copyright (c) 2011 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/service'
|
20
|
-
require 'chef/provider/service/simple'
|
21
|
-
require 'chef/mixin/command'
|
22
|
-
|
23
|
-
class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
24
|
-
def load_current_resource
|
25
|
-
@current_resource = Chef::Resource::Service.new(@new_resource.name)
|
26
|
-
@current_resource.service_name(@new_resource.service_name)
|
27
|
-
|
28
|
-
if @new_resource.status_command
|
29
|
-
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
|
30
|
-
|
31
|
-
begin
|
32
|
-
if run_command_with_systems_locale(:command => @new_resource.status_command) == 0
|
33
|
-
@current_resource.running(true)
|
34
|
-
end
|
35
|
-
rescue Chef::Exceptions::Exec
|
36
|
-
@current_resource.running(false)
|
37
|
-
nil
|
38
|
-
end
|
39
|
-
else
|
40
|
-
@current_resource.running(is_active?)
|
41
|
-
end
|
42
|
-
|
43
|
-
@current_resource.enabled(is_enabled?)
|
44
|
-
@current_resource
|
45
|
-
end
|
46
|
-
|
47
|
-
def start_service
|
48
|
-
if @current_resource.running
|
49
|
-
Chef::Log.debug("#{@new_resource} already running, not starting")
|
50
|
-
else
|
51
|
-
if @new_resource.start_command
|
52
|
-
super
|
53
|
-
else
|
54
|
-
run_command_with_systems_locale(:command => "/bin/systemctl start #{@new_resource.service_name}")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def stop_service
|
60
|
-
unless @current_resource.running
|
61
|
-
Chef::Log.debug("#{@new_resource} not running, not stopping")
|
62
|
-
else
|
63
|
-
if @new_resource.stop_command
|
64
|
-
super
|
65
|
-
else
|
66
|
-
run_command_with_systems_locale(:command => "/bin/systemctl stop #{@new_resource.service_name}")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def restart_service
|
72
|
-
if @new_resource.restart_command
|
73
|
-
super
|
74
|
-
else
|
75
|
-
run_command_with_systems_locale(:command => "/bin/systemctl restart #{@new_resource.service_name}")
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def reload_service
|
80
|
-
if @new_resource.reload_command
|
81
|
-
super
|
82
|
-
else
|
83
|
-
run_command_with_systems_locale(:command => "/bin/systemctl reload #{@new_resource.service_name}")
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def enable_service
|
88
|
-
run_command_with_systems_locale(:command => "/bin/systemctl enable #{@new_resource.service_name}")
|
89
|
-
end
|
90
|
-
|
91
|
-
def disable_service
|
92
|
-
run_command_with_systems_locale(:command => "/bin/systemctl disable #{@new_resource.service_name}")
|
93
|
-
end
|
94
|
-
|
95
|
-
def is_active?
|
96
|
-
run_command_with_systems_locale({:command => "/bin/systemctl is-active #{@new_resource.service_name}", :ignore_failure => true}) == 0
|
97
|
-
end
|
98
|
-
|
99
|
-
def is_enabled?
|
100
|
-
run_command_with_systems_locale({:command => "/bin/systemctl is-enabled #{@new_resource.service_name}", :ignore_failure => true}) == 0
|
101
|
-
end
|
102
|
-
end
|