chef 0.9.16 → 0.9.18
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +20 -3
- data/lib/chef/provider/service/arch.rb +35 -28
- data/lib/chef/shef.rb +1 -0
- data/lib/chef/version.rb +1 -1
- metadata +2 -2
@@ -24,7 +24,7 @@ class Chef
|
|
24
24
|
class Provider
|
25
25
|
class Package
|
26
26
|
class Dpkg < Chef::Provider::Package::Apt
|
27
|
-
DPKG_INFO = /([a-z\d\-\+]+)\t([\w\d
|
27
|
+
DPKG_INFO = /([a-z\d\-\+]+)\t([\w\d.~-]+)/
|
28
28
|
DPKG_INSTALLED = /^Status: install ok installed/
|
29
29
|
DPKG_VERSION = /^Version: (.+)$/
|
30
30
|
|
@@ -84,9 +84,18 @@ class Chef
|
|
84
84
|
Chef::Log.debug("zypper current resource #{@current_resource}")
|
85
85
|
@current_resource
|
86
86
|
end
|
87
|
+
|
88
|
+
#Gets the zypper Version from command output (Returns Floating Point number)
|
89
|
+
def zypper_version()
|
90
|
+
`zypper -V 2>&1`.scan(/\d+/).join(".").to_f
|
91
|
+
end
|
87
92
|
|
88
93
|
def install_package(name, version)
|
89
|
-
if
|
94
|
+
if zypper_version < 1.0
|
95
|
+
run_command(
|
96
|
+
:command => "zypper install -y #{name}"
|
97
|
+
)
|
98
|
+
elsif version
|
90
99
|
run_command(
|
91
100
|
:command => "zypper -n --no-gpg-checks install -l #{name}=#{version}"
|
92
101
|
)
|
@@ -98,7 +107,11 @@ class Chef
|
|
98
107
|
end
|
99
108
|
|
100
109
|
def upgrade_package(name, version)
|
101
|
-
if
|
110
|
+
if zypper_version < 1.0
|
111
|
+
run_command(
|
112
|
+
:command => "zypper install -y #{name}"
|
113
|
+
)
|
114
|
+
elsif version
|
102
115
|
run_command(
|
103
116
|
:command => "zypper -n --no-gpg-checks install -l #{name}=#{version}"
|
104
117
|
)
|
@@ -110,7 +123,11 @@ class Chef
|
|
110
123
|
end
|
111
124
|
|
112
125
|
def remove_package(name, version)
|
113
|
-
if
|
126
|
+
if zypper_version < 1.0
|
127
|
+
run_command(
|
128
|
+
:command => "zypper remove -y #{name}"
|
129
|
+
)
|
130
|
+
elsif version
|
114
131
|
run_command(
|
115
132
|
:command => "zypper -n --no-gpg-checks remove #{name}=#{version}"
|
116
133
|
)
|
@@ -20,16 +20,16 @@ require 'chef/provider/service/init'
|
|
20
20
|
require 'chef/mixin/command'
|
21
21
|
|
22
22
|
class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
23
|
-
|
23
|
+
|
24
24
|
def initialize(new_resource, run_context)
|
25
25
|
super
|
26
26
|
@init_command = "/etc/rc.d/#{@new_resource.service_name}"
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def load_current_resource
|
30
|
-
|
30
|
+
|
31
31
|
raise Chef::Exceptions::Service unless ::File.exists?("/etc/rc.conf")
|
32
|
-
raise Chef::Exceptions::Service unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/)
|
32
|
+
raise Chef::Exceptions::Service unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
|
33
33
|
|
34
34
|
super
|
35
35
|
|
@@ -38,38 +38,46 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
|
38
38
|
@current_resource
|
39
39
|
end
|
40
40
|
|
41
|
+
# Get list of all daemons from the file '/etc/rc.conf'.
|
42
|
+
# Mutiple lines and background form are supported. Example:
|
43
|
+
# DAEMONS=(\
|
44
|
+
# foobar \
|
45
|
+
# @example \
|
46
|
+
# !net \
|
47
|
+
# )
|
41
48
|
def daemons
|
42
49
|
entries = []
|
43
|
-
if ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/)
|
44
|
-
entries += $1.split(
|
50
|
+
if ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
|
51
|
+
entries += $1.gsub(/\\?[\r\n]/, ' ').gsub(/# *[^ ]+/,' ').split(' ') if $1.length > 0
|
45
52
|
end
|
46
|
-
|
53
|
+
|
47
54
|
yield(entries) if block_given?
|
48
|
-
|
55
|
+
|
49
56
|
entries
|
50
57
|
end
|
51
|
-
|
58
|
+
|
59
|
+
# FIXME: Multiple entries of DAEMONS will cause very bad results :)
|
52
60
|
def update_daemons(entries)
|
53
|
-
content = ::File.read("/etc/rc.conf").gsub(/DAEMONS=\((.*)\)
|
61
|
+
content = ::File.read("/etc/rc.conf").gsub(/DAEMONS=\((.*)\)/m, "DAEMONS=(#{entries.join(' ')})")
|
54
62
|
::File.open("/etc/rc.conf", "w") do |f|
|
55
63
|
f.write(content)
|
56
64
|
end
|
57
65
|
end
|
58
|
-
|
66
|
+
|
59
67
|
def enable_service()
|
60
68
|
new_daemons = []
|
61
69
|
entries = daemons
|
62
|
-
|
63
|
-
if entries.include?(new_resource.service_name)
|
64
|
-
# exists and already enabled
|
65
|
-
new_daemons += entries
|
70
|
+
|
71
|
+
if entries.include?(new_resource.service_name) or entries.include?("@#{new_resource.service_name}")
|
72
|
+
# exists and already enabled (or already enabled as a background service)
|
73
|
+
# new_daemons += entries
|
66
74
|
else
|
67
75
|
if entries.include?("!#{new_resource.service_name}")
|
68
76
|
# exists but disabled
|
69
77
|
entries.each do |daemon|
|
70
|
-
if daemon == "!#{new_resource.service_name}"
|
78
|
+
if daemon == "!#{new_resource.service_name}"
|
71
79
|
new_daemons << new_resource.service_name
|
72
|
-
else
|
80
|
+
else
|
73
81
|
new_daemons << daemon
|
74
82
|
end
|
75
83
|
end
|
@@ -78,32 +86,31 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
|
78
86
|
new_daemons += entries
|
79
87
|
new_daemons << new_resource.service_name
|
80
88
|
end
|
89
|
+
update_daemons(new_daemons)
|
81
90
|
end
|
82
|
-
|
83
|
-
update_daemons(new_daemons)
|
84
91
|
end
|
85
|
-
|
92
|
+
|
86
93
|
def disable_service()
|
87
94
|
new_daemons = []
|
88
95
|
entries = daemons
|
89
|
-
|
96
|
+
|
90
97
|
if entries.include?("!#{new_resource.service_name}")
|
91
98
|
# exists and disabled
|
92
|
-
new_daemons += entries
|
99
|
+
# new_daemons += entries
|
93
100
|
else
|
94
|
-
if entries.include?(new_resource.service_name)
|
95
|
-
# exists but enabled
|
101
|
+
if entries.include?(new_resource.service_name) or entries.include?("@#{new_resource.service_name}")
|
102
|
+
# exists but enabled (or enabled as a back-ground service)
|
103
|
+
# FIXME: Does arch support !@foobar ?
|
96
104
|
entries.each do |daemon|
|
97
|
-
if
|
105
|
+
if [new_resource.service_name, "@#{new_resource.service_name}"].include?(daemon)
|
98
106
|
new_daemons << "!#{new_resource.service_name}"
|
99
|
-
else
|
107
|
+
else
|
100
108
|
new_daemons << daemon
|
101
109
|
end
|
102
110
|
end
|
103
111
|
end
|
112
|
+
update_daemons(new_daemons)
|
104
113
|
end
|
105
|
-
|
106
|
-
update_daemons(new_daemons)
|
107
114
|
end
|
108
115
|
|
109
116
|
end
|
data/lib/chef/shef.rb
CHANGED
data/lib/chef/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.18
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Adam Jacob
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-29 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|