chef 0.9.6 → 0.9.8.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef/application.rb +19 -3
- data/lib/chef/application/client.rb +7 -8
- data/lib/chef/application/knife.rb +9 -3
- data/lib/chef/application/solo.rb +5 -5
- data/lib/chef/cache/checksum.rb +2 -2
- data/lib/chef/client.rb +30 -64
- data/lib/chef/config.rb +52 -30
- data/lib/chef/cookbook/metadata.rb +12 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +211 -0
- data/lib/chef/cookbook_uploader.rb +102 -0
- data/lib/chef/cookbook_version.rb +47 -30
- data/lib/chef/couchdb.rb +1 -11
- data/lib/chef/exceptions.rb +1 -0
- data/lib/chef/file_access_control.rb +1 -1
- data/lib/chef/index_queue/amqp_client.rb +10 -3
- data/lib/chef/knife.rb +154 -58
- data/lib/chef/knife/bootstrap.rb +84 -48
- data/lib/chef/knife/bootstrap/centos5-gems.erb +41 -0
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +38 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +44 -0
- data/lib/chef/knife/client_bulk_delete.rb +1 -1
- data/lib/chef/knife/client_create.rb +1 -1
- data/lib/chef/knife/client_delete.rb +1 -1
- data/lib/chef/knife/client_edit.rb +1 -1
- data/lib/chef/knife/client_list.rb +1 -1
- data/lib/chef/knife/client_reregister.rb +1 -1
- data/lib/chef/knife/client_show.rb +1 -1
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/configure_client.rb +1 -1
- data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
- data/lib/chef/knife/cookbook_create.rb +159 -0
- data/lib/chef/knife/cookbook_delete.rb +6 -6
- data/lib/chef/knife/cookbook_download.rb +1 -1
- data/lib/chef/knife/cookbook_list.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +1 -1
- data/lib/chef/knife/cookbook_metadata_from_file.rb +1 -1
- data/lib/chef/knife/cookbook_show.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +2 -1
- data/lib/chef/knife/cookbook_site_list.rb +2 -1
- data/lib/chef/knife/cookbook_site_search.rb +2 -1
- data/lib/chef/knife/cookbook_site_share.rb +108 -0
- data/lib/chef/knife/cookbook_site_show.rb +2 -1
- data/lib/chef/knife/cookbook_site_unshare.rb +52 -0
- data/lib/chef/knife/cookbook_site_vendor.rb +3 -2
- data/lib/chef/knife/cookbook_test.rb +1 -1
- data/lib/chef/knife/cookbook_upload.rb +22 -155
- data/lib/chef/knife/data_bag_create.rb +2 -1
- data/lib/chef/knife/data_bag_delete.rb +2 -1
- data/lib/chef/knife/data_bag_edit.rb +2 -1
- data/lib/chef/knife/data_bag_from_file.rb +2 -1
- data/lib/chef/knife/data_bag_list.rb +2 -1
- data/lib/chef/knife/data_bag_show.rb +2 -1
- data/lib/chef/knife/ec2_instance_data.rb +1 -1
- data/lib/chef/knife/ec2_server_create.rb +16 -4
- data/lib/chef/knife/ec2_server_delete.rb +8 -2
- data/lib/chef/knife/ec2_server_list.rb +8 -2
- data/lib/chef/knife/index_rebuild.rb +1 -1
- data/lib/chef/knife/node_bulk_delete.rb +1 -1
- data/lib/chef/knife/node_create.rb +1 -1
- data/lib/chef/knife/node_delete.rb +1 -1
- data/lib/chef/knife/node_edit.rb +1 -1
- data/lib/chef/knife/node_from_file.rb +1 -1
- data/lib/chef/knife/node_list.rb +1 -1
- data/lib/chef/knife/node_run_list_add.rb +1 -1
- data/lib/chef/knife/node_run_list_remove.rb +1 -1
- data/lib/chef/knife/node_show.rb +1 -1
- data/lib/chef/knife/rackspace_server_create.rb +1 -1
- data/lib/chef/knife/rackspace_server_delete.rb +1 -1
- data/lib/chef/knife/rackspace_server_list.rb +1 -1
- data/lib/chef/knife/recipe_list.rb +1 -1
- data/lib/chef/knife/role_bulk_delete.rb +1 -1
- data/lib/chef/knife/role_create.rb +1 -1
- data/lib/chef/knife/role_delete.rb +1 -1
- data/lib/chef/knife/role_edit.rb +1 -1
- data/lib/chef/knife/role_from_file.rb +1 -1
- data/lib/chef/knife/role_list.rb +1 -1
- data/lib/chef/knife/role_show.rb +1 -1
- data/lib/chef/knife/search.rb +1 -1
- data/lib/chef/knife/slicehost_images_list.rb +1 -1
- data/lib/chef/knife/slicehost_server_create.rb +1 -1
- data/lib/chef/knife/slicehost_server_delete.rb +1 -1
- data/lib/chef/knife/slicehost_server_list.rb +1 -1
- data/lib/chef/knife/ssh.rb +49 -9
- data/lib/chef/knife/status.rb +2 -2
- data/lib/chef/knife/terremark_server_create.rb +1 -1
- data/lib/chef/knife/terremark_server_delete.rb +1 -1
- data/lib/chef/knife/terremark_server_list.rb +1 -1
- data/lib/chef/mixin/command.rb +17 -204
- data/lib/chef/mixin/command/unix.rb +215 -0
- data/lib/chef/mixin/command/windows.rb +72 -0
- data/lib/chef/mixin/find_preferred_file.rb +3 -3
- data/lib/chef/mixin/language.rb +64 -23
- data/lib/chef/node.rb +27 -3
- data/lib/chef/node/attribute.rb +20 -10
- data/lib/chef/platform.rb +3 -9
- data/lib/chef/provider/cron.rb +1 -1
- data/lib/chef/provider/deploy.rb +4 -1
- data/lib/chef/provider/group.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +2 -2
- data/lib/chef/provider/mount/mount.rb +6 -6
- data/lib/chef/provider/package/easy_install.rb +8 -7
- data/lib/chef/provider/package/pacman.rb +1 -1
- data/lib/chef/provider/package/rpm.rb +4 -4
- data/lib/chef/provider/package/solaris.rb +127 -0
- data/lib/chef/provider/package/yum.rb +51 -28
- data/lib/chef/provider/remote_directory.rb +5 -2
- data/lib/chef/provider/remote_file.rb +1 -1
- data/lib/chef/provider/ruby_block.rb +1 -0
- data/lib/chef/provider/script.rb +2 -2
- data/lib/chef/provider/service/debian.rb +40 -4
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/upstart.rb +3 -10
- data/lib/chef/provider/user/dscl.rb +2 -2
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +7 -8
- data/lib/chef/resource/service.rb +17 -0
- data/lib/chef/resource/solaris_package.rb +36 -0
- data/lib/chef/resource/yum_package.rb +11 -4
- data/lib/chef/rest/rest_request.rb +18 -1
- data/lib/chef/run_list/run_list_expansion.rb +4 -0
- data/lib/chef/run_list/run_list_item.rb +8 -1
- data/lib/chef/shef/ext.rb +1 -1
- data/lib/chef/shef/shef_session.rb +7 -3
- data/lib/chef/tasks/chef_repo.rake +1 -0
- data/lib/chef/version.rb +2 -1
- metadata +23 -8
- data/lib/chef/cache/file_cache_by_checksum.rb +0 -52
@@ -74,14 +74,15 @@ class Chef
|
|
74
74
|
|
75
75
|
# do a dry run to get the latest version
|
76
76
|
command = "#{easy_install_binary_path} -n #{@new_resource.package_name}"
|
77
|
-
pid, stdin, stdout, stderr
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
status = popen4(command) do |pid, stdin, stdout, stderr|
|
78
|
+
dry_run_output = ""
|
79
|
+
stdout.each do |line|
|
80
|
+
dry_run_output << line
|
81
|
+
end
|
82
|
+
dry_run_output[/(.*)Best match: (.*) (.*)\n/]
|
83
|
+
@candidate_version = $3
|
84
|
+
@candidate_version
|
81
85
|
end
|
82
|
-
dry_run_output[/(.*)Best match: (.*) (.*)\n/]
|
83
|
-
@candidate_version = $3
|
84
|
-
@candidate_version
|
85
86
|
end
|
86
87
|
|
87
88
|
def install_package(name, version)
|
@@ -55,7 +55,7 @@ class Chef
|
|
55
55
|
status = popen4("pacman -Ss #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
|
56
56
|
stdout.each do |line|
|
57
57
|
case line
|
58
|
-
when /^(extra|core|community)\/#{@new_resource.package_name} (.+)$/
|
58
|
+
when /^(extra|core|community)\/#{Regexp.escape(@new_resource.package_name)} (.+)$/
|
59
59
|
# $2 contains a string like "4.4.0-1 (kde kdenetwork)" or "3.10-4 (base)"
|
60
60
|
# simply split by space and use first token
|
61
61
|
@candidate_version = $2.split(" ").first
|
@@ -71,11 +71,11 @@ class Chef
|
|
71
71
|
def install_package(name, version)
|
72
72
|
unless @current_resource.version
|
73
73
|
run_command_with_systems_locale(
|
74
|
-
:command => "rpm -i #{@new_resource.source}"
|
74
|
+
:command => "rpm #{@new_resource.options} -i #{@new_resource.source}"
|
75
75
|
)
|
76
76
|
else
|
77
77
|
run_command_with_systems_locale(
|
78
|
-
:command => "rpm -U #{@new_resource.source}"
|
78
|
+
:command => "rpm #{@new_resource.options} -U #{@new_resource.source}"
|
79
79
|
)
|
80
80
|
end
|
81
81
|
end
|
@@ -85,11 +85,11 @@ class Chef
|
|
85
85
|
def remove_package(name, version)
|
86
86
|
if version
|
87
87
|
run_command_with_systems_locale(
|
88
|
-
:command => "rpm -e #{name}-#{version}"
|
88
|
+
:command => "rpm #{@new_resource.options} -e #{name}-#{version}"
|
89
89
|
)
|
90
90
|
else
|
91
91
|
run_command_with_systems_locale(
|
92
|
-
:command => "rpm -e #{name}"
|
92
|
+
:command => "rpm #{@new_resource.options} -e #{name}"
|
93
93
|
)
|
94
94
|
end
|
95
95
|
end
|
@@ -0,0 +1,127 @@
|
|
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
|
+
require 'chef/provider/package'
|
19
|
+
require 'chef/mixin/command'
|
20
|
+
require 'chef/resource/package'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Provider
|
24
|
+
class Package
|
25
|
+
class Solaris < Chef::Provider::Package
|
26
|
+
|
27
|
+
# def initialize(*args)
|
28
|
+
# super
|
29
|
+
# @current_resource = Chef::Resource::Package.new(@new_resource.name)
|
30
|
+
# end
|
31
|
+
|
32
|
+
def load_current_resource
|
33
|
+
@current_resource = Chef::Resource::Package.new(@new_resource.name)
|
34
|
+
@current_resource.package_name(@new_resource.package_name)
|
35
|
+
@new_resource.version(nil)
|
36
|
+
|
37
|
+
if @new_resource.source
|
38
|
+
unless ::File.exists?(@new_resource.source)
|
39
|
+
raise Chef::Exceptions::Package, "Package #{@new_resource.name} not found: #{@new_resource.source}"
|
40
|
+
end
|
41
|
+
|
42
|
+
Chef::Log.debug("Checking pkg status for #{@new_resource.package_name}")
|
43
|
+
status = popen4("pkginfo -l -d #{@new_resource.source} #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
|
44
|
+
stdout.each do |line|
|
45
|
+
case line
|
46
|
+
when /VERSION:\s+(.+)/
|
47
|
+
@new_resource.version($1)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
elsif Array(@new_resource.action).include?(:install)
|
52
|
+
raise Chef::Exceptions::Package, "Source for package #{@new_resource.name} required for action install"
|
53
|
+
end
|
54
|
+
|
55
|
+
Chef::Log.debug("Checking install state for #{@current_resource.package_name}")
|
56
|
+
status = popen4("pkginfo -l #{@current_resource.package_name}") do |pid, stdin, stdout, stderr|
|
57
|
+
stdout.each do |line|
|
58
|
+
case line
|
59
|
+
when /VERSION:\s+(.+)/
|
60
|
+
Chef::Log.debug("Package #{@current_resource.package_name} #{$1} is already installed")
|
61
|
+
@current_resource.version($1)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
unless status.exitstatus == 0 || status.exitstatus == 1
|
67
|
+
raise Chef::Exceptions::Package, "pkginfo failed - #{status.inspect}!"
|
68
|
+
end
|
69
|
+
|
70
|
+
unless @current_resource.version.nil?
|
71
|
+
@current_resource.version(nil)
|
72
|
+
end
|
73
|
+
|
74
|
+
@current_resource
|
75
|
+
end
|
76
|
+
|
77
|
+
def candidate_version
|
78
|
+
return @candidate_version if @candidate_version
|
79
|
+
status = popen4("pkginfo -l -d #{@new_resource.source} #{new_resource.package_name}") do |pid, stdin, stdout, stderr|
|
80
|
+
stdout.each_line do |line|
|
81
|
+
case line
|
82
|
+
when /VERSION:\s+(.+)/
|
83
|
+
@candidate_version = $1
|
84
|
+
@new_resource.version($1)
|
85
|
+
Chef::Log.debug("candidate_version: setting install candidate version to #{@candidate_version}")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
unless status.exitstatus == 0
|
90
|
+
raise Chef::Exceptions::Package, "pkginfo -l -d #{@new_resource.source} - #{status.inspect}!"
|
91
|
+
end
|
92
|
+
@candidate_version
|
93
|
+
end
|
94
|
+
|
95
|
+
def install_package(name, version)
|
96
|
+
Chef::Log.debug("Options: #{@new_resource.options}")
|
97
|
+
if @new_resource.options.nil?
|
98
|
+
run_command_with_systems_locale(
|
99
|
+
:command => "pkgadd -n -d #{@new_resource.source} all"
|
100
|
+
)
|
101
|
+
Chef::Log.debug("Installed package: #{@new_resource.package_name} #{@new_resource.version} from: #{@new_resource.source}")
|
102
|
+
else
|
103
|
+
run_command_with_systems_locale(
|
104
|
+
:command => "pkgadd -n#{expand_options(@new_resource.options)} -d #{@new_resource.source} all"
|
105
|
+
)
|
106
|
+
Chef::Log.debug("Installed package: #{@new_resource.package_name} #{@new_resource.version} from: #{@new_resource.source}")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def remove_package(name, version)
|
111
|
+
if @new_resource.options.nil?
|
112
|
+
run_command_with_systems_locale(
|
113
|
+
:command => "pkgrm -n #{name}"
|
114
|
+
)
|
115
|
+
Chef::Log.debug("Removed package #{@new_resource.package_name} #{@new_resource.version}")
|
116
|
+
else
|
117
|
+
run_command_with_systems_locale(
|
118
|
+
:command => "pkgrm -n#{expand_options(@new_resource.options)} #{name}"
|
119
|
+
)
|
120
|
+
Chef::Log.debug("Removed package #{@new_resource.package_name} #{@new_resource.version}")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -24,8 +24,8 @@ require 'singleton'
|
|
24
24
|
class Chef
|
25
25
|
class Provider
|
26
26
|
class Package
|
27
|
-
class Yum < Chef::Provider::Package
|
28
|
-
|
27
|
+
class Yum < Chef::Provider::Package
|
28
|
+
|
29
29
|
class YumCache
|
30
30
|
include Chef::Mixin::Command
|
31
31
|
include Singleton
|
@@ -68,8 +68,11 @@ class Chef
|
|
68
68
|
if !@data.has_key?(name)
|
69
69
|
@data[name] = Hash.new
|
70
70
|
end
|
71
|
-
|
72
|
-
|
71
|
+
if !@data[name].has_key?(type_sym)
|
72
|
+
@data[name][type_sym] = Hash.new
|
73
|
+
end
|
74
|
+
@data[name][type_sym][arch] = { :epoch => epoch, :version => version,
|
75
|
+
:release => release }
|
73
76
|
end
|
74
77
|
|
75
78
|
error = stderr.readlines
|
@@ -83,38 +86,58 @@ class Chef
|
|
83
86
|
end
|
84
87
|
alias :reload :load_data
|
85
88
|
|
86
|
-
def version(package_name, type)
|
89
|
+
def version(package_name, type, arch)
|
87
90
|
if (x = @data[package_name])
|
88
91
|
if (y = x[type])
|
89
|
-
|
92
|
+
if arch
|
93
|
+
if (z = y[arch])
|
94
|
+
return "#{z[:version]}-#{z[:release]}"
|
95
|
+
end
|
96
|
+
else
|
97
|
+
# no arch specified - take the first match
|
98
|
+
z = y.to_a[0][1]
|
99
|
+
return "#{z[:version]}-#{z[:release]}"
|
100
|
+
end
|
90
101
|
end
|
91
102
|
end
|
92
103
|
|
93
104
|
nil
|
94
105
|
end
|
95
106
|
|
96
|
-
def installed_version(package_name)
|
97
|
-
version(package_name, :installed)
|
107
|
+
def installed_version(package_name, arch)
|
108
|
+
version(package_name, :installed, arch)
|
98
109
|
end
|
99
110
|
|
100
|
-
def candidate_version(package_name)
|
101
|
-
version(package_name, :available)
|
111
|
+
def candidate_version(package_name, arch)
|
112
|
+
version(package_name, :available, arch)
|
102
113
|
end
|
103
|
-
|
114
|
+
|
104
115
|
def flush
|
105
116
|
@data.clear
|
106
117
|
end
|
107
118
|
end
|
108
119
|
|
109
120
|
def initialize(new_resource, run_context)
|
110
|
-
@yum = YumCache.instance
|
111
121
|
super
|
122
|
+
@yum = YumCache.instance
|
123
|
+
end
|
124
|
+
|
125
|
+
def arch
|
126
|
+
if @new_resource.respond_to?("arch")
|
127
|
+
@new_resource.arch
|
128
|
+
else
|
129
|
+
nil
|
130
|
+
end
|
112
131
|
end
|
113
|
-
|
132
|
+
|
133
|
+
def yum_arch
|
134
|
+
arch ? ".#{arch}" : nil
|
135
|
+
end
|
136
|
+
|
114
137
|
def load_current_resource
|
115
138
|
@current_resource = Chef::Resource::Package.new(@new_resource.name)
|
116
139
|
@current_resource.package_name(@new_resource.package_name)
|
117
|
-
|
140
|
+
|
118
141
|
if @new_resource.source
|
119
142
|
unless ::File.exists?(@new_resource.source)
|
120
143
|
raise Chef::Exceptions::Package, "Package #{@new_resource.name} not found: #{@new_resource.source}"
|
@@ -132,42 +155,42 @@ class Chef
|
|
132
155
|
end
|
133
156
|
end
|
134
157
|
|
135
|
-
Chef::Log.debug("Checking yum info for #{@new_resource.package_name}")
|
136
|
-
|
158
|
+
Chef::Log.debug("Checking yum info for #{@new_resource.package_name}#{yum_arch}")
|
159
|
+
|
137
160
|
@yum.refresh
|
138
161
|
|
139
|
-
installed_version = @yum.installed_version(@new_resource.package_name)
|
140
|
-
@candidate_version = @yum.candidate_version(@new_resource.package_name)
|
141
|
-
|
162
|
+
installed_version = @yum.installed_version(@new_resource.package_name, arch)
|
163
|
+
@candidate_version = @yum.candidate_version(@new_resource.package_name, arch)
|
164
|
+
|
142
165
|
@current_resource.version(installed_version)
|
143
166
|
if candidate_version
|
144
167
|
@candidate_version = candidate_version
|
145
168
|
else
|
146
169
|
@candidate_version = installed_version
|
147
170
|
end
|
148
|
-
|
171
|
+
|
149
172
|
@current_resource
|
150
173
|
end
|
151
174
|
|
152
175
|
def install_package(name, version)
|
153
176
|
if @new_resource.source
|
154
177
|
run_command_with_systems_locale(
|
155
|
-
:command => "yum -d0 -e0 -y localinstall #{@new_resource.source}"
|
178
|
+
:command => "yum -d0 -e0 -y #{@new_resource.options} localinstall #{@new_resource.source}"
|
156
179
|
)
|
157
180
|
else
|
158
181
|
run_command_with_systems_locale(
|
159
|
-
:command => "yum -d0 -e0 -y install #{name}-#{version}"
|
182
|
+
:command => "yum -d0 -e0 -y #{@new_resource.options} install #{name}-#{version}#{yum_arch}"
|
160
183
|
)
|
161
184
|
end
|
162
185
|
@yum.flush
|
163
186
|
end
|
164
|
-
|
187
|
+
|
165
188
|
def upgrade_package(name, version)
|
166
189
|
# If we're not given a version, running update is the correct
|
167
190
|
# option. If we are, then running install_package is right.
|
168
191
|
unless version
|
169
192
|
run_command_with_systems_locale(
|
170
|
-
:command => "yum -d0 -e0 -y update #{name}"
|
193
|
+
:command => "yum -d0 -e0 -y #{@new_resource.options} update #{name}#{yum_arch}"
|
171
194
|
)
|
172
195
|
@yum.flush
|
173
196
|
else
|
@@ -178,21 +201,21 @@ class Chef
|
|
178
201
|
def remove_package(name, version)
|
179
202
|
if version
|
180
203
|
run_command_with_systems_locale(
|
181
|
-
:command => "yum -d0 -e0 -y remove #{name}-#{version}"
|
204
|
+
:command => "yum -d0 -e0 -y #{@new_resource.options} remove #{name}-#{version}#{yum_arch}"
|
182
205
|
)
|
183
206
|
else
|
184
207
|
run_command_with_systems_locale(
|
185
|
-
:command => "yum -d0 -e0 -y remove #{name}"
|
208
|
+
:command => "yum -d0 -e0 -y #{@new_resource.options} remove #{name}#{yum_arch}"
|
186
209
|
)
|
187
210
|
end
|
188
211
|
|
189
212
|
@yum.flush
|
190
213
|
end
|
191
|
-
|
214
|
+
|
192
215
|
def purge_package(name, version)
|
193
216
|
remove_package(name, version)
|
194
217
|
end
|
195
|
-
|
218
|
+
|
196
219
|
end
|
197
220
|
end
|
198
221
|
end
|
@@ -36,8 +36,11 @@ class Chef
|
|
36
36
|
super
|
37
37
|
Chef::Log.debug("Doing a remote recursive directory transfer for #{@new_resource}")
|
38
38
|
|
39
|
-
files_to_purge = Set.new
|
40
|
-
|
39
|
+
files_to_purge = Set.new(
|
40
|
+
Dir.glob(::File.join(@new_resource.path, '**', '*'), ::File::FNM_DOTMATCH).select do |name|
|
41
|
+
name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
|
42
|
+
end
|
43
|
+
)
|
41
44
|
files_to_transfer.each do |cookbook_file_relative_path|
|
42
45
|
create_cookbook_file(cookbook_file_relative_path)
|
43
46
|
files_to_purge.delete(::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)))
|
@@ -71,7 +71,7 @@ class Chef
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def current_resource_matches_target_checksum?
|
74
|
-
@new_resource.checksum && @current_resource.checksum && @current_resource.checksum =~ /^#{@new_resource.checksum}/
|
74
|
+
@new_resource.checksum && @current_resource.checksum && @current_resource.checksum =~ /^#{Regexp.escape(@new_resource.checksum)}/
|
75
75
|
end
|
76
76
|
|
77
77
|
def matches_current_checksum?(candidate_file)
|
data/lib/chef/provider/script.rb
CHANGED
@@ -29,7 +29,7 @@ class Chef
|
|
29
29
|
|
30
30
|
set_owner_and_group
|
31
31
|
|
32
|
-
@new_resource.command("#{@new_resource.interpreter} #{script_file.path}")
|
32
|
+
@new_resource.command("\"#{@new_resource.interpreter}\" \"#{script_file.path}\"")
|
33
33
|
super
|
34
34
|
ensure
|
35
35
|
unlink_script_file
|
@@ -52,4 +52,4 @@ class Chef
|
|
52
52
|
|
53
53
|
end
|
54
54
|
end
|
55
|
-
end
|
55
|
+
end
|
@@ -25,7 +25,8 @@ class Chef
|
|
25
25
|
class Service
|
26
26
|
class Debian < Chef::Provider::Service::Init
|
27
27
|
UPDATE_RC_D_ENABLED_MATCHES = /etc\/rc[\dS].d\/S|not installed/i
|
28
|
-
|
28
|
+
UPDATE_RC_D_PRIORITIES = /etc\/rc([\dS]).d\/([SK])(\d\d)/i
|
29
|
+
|
29
30
|
def load_current_resource
|
30
31
|
super
|
31
32
|
|
@@ -51,16 +52,51 @@ class Chef
|
|
51
52
|
assert_update_rcd_available
|
52
53
|
|
53
54
|
status = popen4("/usr/sbin/update-rc.d -n -f #{@current_resource.service_name} remove") do |pid, stdin, stdout, stderr|
|
55
|
+
priority = {}
|
56
|
+
enabled = false
|
57
|
+
|
54
58
|
stdout.each_line do |line|
|
55
|
-
|
59
|
+
if UPDATE_RC_D_PRIORITIES =~ line
|
60
|
+
priority[$1] = [($2 == "S" ? :start : :stop), $3]
|
61
|
+
end
|
62
|
+
if line =~ UPDATE_RC_D_ENABLED_MATCHES
|
63
|
+
enabled = true
|
64
|
+
end
|
56
65
|
end
|
66
|
+
@current_resource.enabled enabled
|
67
|
+
@current_resource.priority priority
|
57
68
|
end
|
58
69
|
|
59
70
|
unless status.exitstatus == 0
|
60
71
|
raise Chef::Exceptions::Service, "/usr/sbin/update-rc.d -n -f #{@current_resource.service_name} failed - #{status.inspect}"
|
61
72
|
end
|
62
|
-
|
63
|
-
|
73
|
+
@current_resource.enabled
|
74
|
+
end
|
75
|
+
|
76
|
+
def enable_service()
|
77
|
+
# If we have a priority which is just a number, we have to
|
78
|
+
# construct the actual priority object
|
79
|
+
|
80
|
+
if @new_resource.priority.is_a? Integer
|
81
|
+
run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} defaults #{@new_resource.priority} #{100 - @new_resource.priority}")
|
82
|
+
elsif @new_resource.priority.is_a? Hash
|
83
|
+
args = ""
|
84
|
+
@new_resource.priority.each do |level, o|
|
85
|
+
action = o[0]
|
86
|
+
priority = o[1]
|
87
|
+
args += "#{action} #{priority} #{level} . "
|
88
|
+
end
|
89
|
+
run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} #{args}")
|
90
|
+
else # No priority, go with update-rc.d defaults
|
91
|
+
run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} defaults")
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
def disable_service()
|
97
|
+
run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} disable")
|
98
|
+
# @new_resource.priority({2 => [:stop, 80]})
|
99
|
+
# enable_service
|
64
100
|
end
|
65
101
|
|
66
102
|
end
|