chef 0.7.16 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chef might be problematic. Click here for more details.
- data/README.rdoc +11 -10
- data/bin/chef-client +2 -2
- data/bin/chef-solo +1 -1
- data/bin/knife +27 -0
- data/bin/shef +49 -0
- data/distro/README +2 -0
- data/distro/{debian → common}/man/man1/chef-indexer.1 +0 -0
- data/distro/{debian → common}/man/man1/chef-server.1 +0 -0
- data/distro/{debian → common}/man/man8/chef-client.8 +0 -0
- data/distro/{debian → common}/man/man8/chef-solo.8 +0 -0
- data/distro/common/man/man8/knife.8 +375 -0
- data/distro/redhat/etc/init.d/chef-client +8 -4
- data/distro/redhat/etc/init.d/chef-server +16 -15
- data/distro/redhat/etc/init.d/chef-server-webui +78 -0
- data/distro/redhat/etc/init.d/chef-solr +76 -0
- data/distro/redhat/etc/init.d/chef-solr-indexer +75 -0
- data/distro/redhat/etc/sysconfig/chef-client +10 -0
- data/distro/redhat/etc/sysconfig/chef-server +10 -0
- data/distro/redhat/etc/sysconfig/chef-server-webui +10 -0
- data/distro/redhat/etc/sysconfig/chef-solr +9 -0
- data/distro/redhat/etc/sysconfig/chef-solr-indexer +7 -0
- data/distro/suse/etc/init.d/chef-client +121 -0
- data/lib/chef.rb +1 -1
- data/lib/chef/api_client.rb +263 -0
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/client.rb +21 -3
- data/lib/chef/application/knife.rb +144 -0
- data/lib/chef/application/server.rb +2 -1
- data/lib/chef/application/solo.rb +9 -2
- data/lib/chef/cache.rb +61 -0
- data/lib/chef/cache/checksum.rb +70 -0
- data/lib/chef/certificate.rb +154 -0
- data/lib/chef/client.rb +123 -220
- data/lib/chef/compile.rb +9 -21
- data/lib/chef/config.rb +67 -10
- data/lib/chef/cookbook.rb +49 -22
- data/lib/chef/cookbook/metadata.rb +85 -5
- data/lib/chef/cookbook_loader.rb +4 -4
- data/lib/chef/couchdb.rb +99 -30
- data/lib/chef/daemon.rb +1 -1
- data/lib/chef/data_bag.rb +215 -0
- data/lib/chef/data_bag_item.rb +219 -0
- data/lib/chef/exceptions.rb +3 -0
- data/lib/chef/index_queue.rb +29 -0
- data/lib/chef/index_queue/amqp_client.rb +106 -0
- data/lib/chef/index_queue/consumer.rb +76 -0
- data/lib/chef/index_queue/indexable.rb +74 -0
- data/lib/chef/knife.rb +309 -0
- data/lib/chef/knife/client_bulk_delete.rb +40 -0
- data/lib/chef/knife/client_create.rb +62 -0
- data/lib/chef/knife/client_delete.rb +37 -0
- data/lib/chef/knife/client_edit.rb +37 -0
- data/lib/chef/knife/client_list.rb +40 -0
- data/lib/chef/knife/client_reregister.rb +48 -0
- data/lib/chef/knife/client_show.rb +42 -0
- data/lib/chef/knife/configure.rb +123 -0
- data/lib/chef/knife/cookbook_bulk_delete.rb +46 -0
- data/lib/chef/knife/cookbook_delete.rb +41 -0
- data/lib/chef/knife/cookbook_download.rb +57 -0
- data/lib/chef/knife/cookbook_list.rb +41 -0
- data/lib/chef/knife/cookbook_metadata.rb +87 -0
- data/lib/chef/knife/cookbook_show.rb +75 -0
- data/lib/chef/knife/cookbook_upload.rb +179 -0
- data/lib/chef/knife/data_bag_create.rb +43 -0
- data/lib/chef/knife/data_bag_delete.rb +43 -0
- data/lib/chef/knife/data_bag_edit.rb +49 -0
- data/lib/chef/knife/data_bag_list.rb +42 -0
- data/lib/chef/knife/data_bag_show.rb +40 -0
- data/lib/chef/knife/ec2_instance_data.rb +46 -0
- data/lib/chef/knife/index_rebuild.rb +51 -0
- data/lib/chef/knife/node_bulk_delete.rb +43 -0
- data/lib/chef/knife/node_create.rb +39 -0
- data/lib/chef/knife/node_delete.rb +36 -0
- data/lib/chef/knife/node_edit.rb +36 -0
- data/lib/chef/knife/node_from_file.rb +42 -0
- data/lib/chef/knife/node_list.rb +41 -0
- data/lib/chef/knife/node_run_list_add.rb +64 -0
- data/lib/chef/knife/node_run_list_remove.rb +45 -0
- data/lib/chef/knife/node_show.rb +46 -0
- data/lib/chef/knife/role_bulk_delete.rb +44 -0
- data/lib/chef/knife/role_create.rb +44 -0
- data/lib/chef/knife/role_delete.rb +36 -0
- data/lib/chef/knife/role_edit.rb +37 -0
- data/lib/chef/knife/role_from_file.rb +46 -0
- data/lib/chef/knife/role_list.rb +40 -0
- data/lib/chef/knife/role_show.rb +43 -0
- data/lib/chef/knife/search.rb +94 -0
- data/lib/chef/knife/ssh.rb +170 -0
- data/lib/chef/log.rb +30 -8
- data/lib/chef/mixin/checksum.rb +2 -7
- data/lib/chef/mixin/command.rb +32 -13
- data/lib/chef/mixin/convert_to_class_name.rb +15 -0
- data/lib/chef/mixin/deep_merge.rb +199 -11
- data/lib/chef/mixin/generate_url.rb +18 -9
- data/lib/chef/mixin/language.rb +29 -1
- data/lib/chef/mixin/language_include_attribute.rb +56 -0
- data/lib/chef/mixin/language_include_recipe.rb +53 -0
- data/lib/chef/mixin/params_validate.rb +25 -12
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +2 -0
- data/lib/chef/mixin/template.rb +11 -1
- data/lib/chef/mixin/xml_escape.rb +87 -0
- data/lib/chef/node.rb +144 -122
- data/lib/chef/openid_registration.rb +12 -5
- data/lib/chef/platform.rb +89 -47
- data/lib/chef/provider/breakpoint.rb +36 -0
- data/lib/chef/provider/cron.rb +5 -6
- data/lib/chef/provider/deploy.rb +43 -10
- data/lib/chef/provider/deploy/revision.rb +2 -3
- data/lib/chef/provider/erl_call.rb +72 -0
- data/lib/chef/provider/file.rb +8 -4
- data/lib/chef/provider/git.rb +10 -5
- data/lib/chef/provider/group/dscl.rb +128 -0
- data/lib/chef/provider/http_request.rb +6 -2
- data/lib/chef/provider/ifconfig.rb +1 -0
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/log.rb +53 -0
- data/lib/chef/provider/mdadm.rb +88 -0
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/package.rb +1 -1
- data/lib/chef/provider/package/easy_install.rb +106 -0
- data/lib/chef/provider/package/pacman.rb +101 -0
- data/lib/chef/provider/package/portage.rb +1 -1
- data/lib/chef/provider/package/rpm.rb +10 -8
- data/lib/chef/provider/package/yum-dump.py +22 -3
- data/lib/chef/provider/package/yum.rb +32 -8
- data/lib/chef/provider/package/zypper.rb +132 -0
- data/lib/chef/provider/remote_directory.rb +58 -49
- data/lib/chef/provider/remote_file.rb +1 -1
- data/lib/chef/provider/route.rb +136 -80
- data/lib/chef/provider/ruby_block.rb +18 -1
- data/lib/chef/provider/service/arch.rb +109 -0
- data/lib/chef/provider/service/freebsd.rb +0 -1
- data/lib/chef/provider/service/simple.rb +2 -3
- data/lib/chef/provider/service/upstart.rb +191 -0
- data/lib/chef/provider/subversion.rb +12 -4
- data/lib/chef/provider/template.rb +85 -53
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +277 -0
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/recipe.rb +2 -41
- data/lib/chef/resource.rb +9 -3
- data/lib/chef/resource/breakpoint.rb +35 -0
- data/lib/chef/resource/deploy.rb +16 -2
- data/lib/chef/resource/easy_install_package.rb +41 -0
- data/lib/chef/resource/erl_call.rb +83 -0
- data/lib/chef/resource/freebsd_package.rb +35 -0
- data/lib/chef/resource/log.rb +62 -0
- data/lib/chef/resource/mdadm.rb +82 -0
- data/lib/chef/resource/pacman_package.rb +33 -0
- data/lib/chef/resource/ruby_block.rb +21 -2
- data/lib/chef/resource/scm.rb +8 -0
- data/lib/chef/resource/subversion.rb +1 -0
- data/lib/chef/resource/user.rb +5 -2
- data/lib/chef/resource/yum_package.rb +36 -0
- data/lib/chef/resource_collection.rb +17 -9
- data/lib/chef/resource_collection/stepable_iterator.rb +124 -0
- data/lib/chef/rest.rb +166 -81
- data/lib/chef/role.rb +114 -38
- data/lib/chef/run_list.rb +15 -6
- data/lib/chef/runner.rb +13 -11
- data/lib/chef/search/query.rb +60 -0
- data/lib/chef/shef.rb +220 -0
- data/lib/chef/shef/ext.rb +297 -0
- data/lib/chef/shef/shef_session.rb +175 -0
- data/lib/chef/streaming_cookbook_uploader.rb +187 -0
- data/lib/chef/tasks/chef_repo.rake +53 -155
- data/lib/chef/util/file_edit.rb +94 -96
- data/lib/chef/webui_user.rb +233 -0
- metadata +219 -63
- data/distro/debian/etc/init.d/chef-indexer +0 -175
- data/distro/redhat/etc/chef/client.rb +0 -16
- data/distro/redhat/etc/chef/indexer.rb +0 -10
- data/distro/redhat/etc/chef/server.rb +0 -22
- data/distro/redhat/etc/init.d/chef-indexer +0 -76
- data/lib/chef/application/indexer.rb +0 -141
- data/lib/chef/queue.rb +0 -145
- data/lib/chef/search.rb +0 -88
- data/lib/chef/search/result.rb +0 -64
- data/lib/chef/search_index.rb +0 -77
- data/lib/chef/util/fileedit.rb +0 -121
@@ -53,8 +53,7 @@ class Chef
|
|
53
53
|
def load_cache
|
54
54
|
begin
|
55
55
|
JSON.parse(Chef::FileCache.load("revision-deploys/#{new_resource.name}"))
|
56
|
-
rescue
|
57
|
-
Chef::Exceptions::FileNotFound
|
56
|
+
rescue Chef::Exceptions::FileNotFound
|
58
57
|
save_cache([])
|
59
58
|
end
|
60
59
|
end
|
@@ -67,4 +66,4 @@ class Chef
|
|
67
66
|
end
|
68
67
|
end
|
69
68
|
end
|
70
|
-
end
|
69
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Joe Williams (<joe@joetify.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Joe Williams
|
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/log'
|
20
|
+
require 'chef/mixin/command'
|
21
|
+
require 'chef/provider'
|
22
|
+
|
23
|
+
class Chef
|
24
|
+
class Provider
|
25
|
+
class ErlCall < Chef::Provider
|
26
|
+
include Chef::Mixin::Command
|
27
|
+
|
28
|
+
def initialize(node, new_resource)
|
29
|
+
super(node, new_resource)
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_current_resource
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def action_run
|
37
|
+
case @new_resource.name_type
|
38
|
+
when "sname"
|
39
|
+
node = "-sname #{@new_resource.node_name}"
|
40
|
+
when "name"
|
41
|
+
node = "-name #{@new_resource.node_name}"
|
42
|
+
end
|
43
|
+
|
44
|
+
if @new_resource.cookie
|
45
|
+
cookie = "-c #{@new_resource.cookie}"
|
46
|
+
else
|
47
|
+
cookie = ""
|
48
|
+
end
|
49
|
+
|
50
|
+
if @new_resource.distributed
|
51
|
+
distributed = "-s"
|
52
|
+
else
|
53
|
+
distributed = ""
|
54
|
+
end
|
55
|
+
|
56
|
+
command = "erl_call -e #{distributed} #{node} #{cookie}"
|
57
|
+
|
58
|
+
status = popen4(command, :waitlast => true) do |pid, stdin, stdout, stderr|
|
59
|
+
Chef::Log.debug("Running erl_call[#{@new_resource.name}]")
|
60
|
+
Chef::Log.debug("erl_call[#{@new_resource.name}] command: #{command}")
|
61
|
+
Chef::Log.debug("erl_call[#{@new_resource.name}] code: #{@new_resource.code}")
|
62
|
+
@new_resource.code.each { |line| stdin.puts "#{line.chomp!}" }
|
63
|
+
stdin.close
|
64
|
+
Chef::Log.info("Ran erl_call[#{@new_resource.name}] successfully")
|
65
|
+
Chef::Log.debug("erl_call[#{@new_resource.name}] output: ")
|
66
|
+
stdout.each { |line| Chef::Log.debug("#{line}")}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/chef/provider/file.rb
CHANGED
@@ -165,12 +165,16 @@ class Chef
|
|
165
165
|
time = Time.now
|
166
166
|
savetime = time.strftime("%Y%m%d%H%M%S")
|
167
167
|
backup_filename = "#{@new_resource.path}.chef-#{savetime}"
|
168
|
-
Chef::
|
169
|
-
|
168
|
+
prefix = Chef::Config[:file_backup_path] || ""
|
169
|
+
if Chef::Config[:file_backup_path]
|
170
|
+
FileUtils.mkdir_p(::File.dirname(Chef::Config[:file_backup_path] + backup_filename))
|
171
|
+
end
|
172
|
+
Chef::Log.info("Backing up #{@new_resource} to #{prefix + backup_filename}")
|
173
|
+
FileUtils.cp(file, prefix + backup_filename, :preserve => true)
|
170
174
|
|
171
175
|
# Clean up after the number of backups
|
172
|
-
slice_number = @new_resource.backup
|
173
|
-
backup_files = Dir["#{@new_resource.path}.chef-*"].sort { |a,b| b <=> a }
|
176
|
+
slice_number = @new_resource.backup
|
177
|
+
backup_files = Dir[prefix + "#{@new_resource.path}.chef-*"].sort { |a,b| b <=> a }
|
174
178
|
if backup_files.length >= @new_resource.backup
|
175
179
|
remainder = backup_files.slice(slice_number..-1)
|
176
180
|
remainder.each do |backup_to_delete|
|
data/lib/chef/provider/git.rb
CHANGED
@@ -36,10 +36,14 @@ class Chef
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def action_checkout
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
if !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination) == ['.','..']
|
40
|
+
clone
|
41
|
+
checkout
|
42
|
+
enable_submodules
|
43
|
+
@new_resource.updated = true
|
44
|
+
else
|
45
|
+
Chef::Log.info "Taking no action, checkout destination #{@new_resource.destination} already exists or is a non-empty directory"
|
46
|
+
end
|
43
47
|
end
|
44
48
|
|
45
49
|
def action_export
|
@@ -117,7 +121,7 @@ class Chef
|
|
117
121
|
end
|
118
122
|
|
119
123
|
# since we're in a local branch already, just reset to specified revision rather than merge
|
120
|
-
sync_command << "#{git} fetch #{@new_resource.remote} && #{git} reset --hard #{revision}"
|
124
|
+
sync_command << "#{git} fetch #{@new_resource.remote} && #{git} fetch #{@new_resource.remote} --tags && #{git} reset --hard #{revision}"
|
121
125
|
Chef::Log.info "Fetching updates from #{new_resource.remote} and resetting to revison #{revision}"
|
122
126
|
run_command(run_options(:command => sync_command.join(" && "), :cwd => @new_resource.destination))
|
123
127
|
end
|
@@ -155,6 +159,7 @@ class Chef
|
|
155
159
|
|
156
160
|
def run_options(run_opts={})
|
157
161
|
run_opts[:user] = @new_resource.user if @new_resource.user
|
162
|
+
run_opts[:group] = @new_resource.group if @new_resource.group
|
158
163
|
run_opts[:environment] = {"GIT_SSH" => @new_resource.ssh_wrapper} if @new_resource.ssh_wrapper
|
159
164
|
run_opts
|
160
165
|
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Dreamcat4 (<dreamcat4@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 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
|
+
class Chef
|
20
|
+
class Provider
|
21
|
+
class Group
|
22
|
+
class Dscl < Chef::Provider::Group
|
23
|
+
|
24
|
+
def dscl(*args)
|
25
|
+
host = "."
|
26
|
+
stdout_result = ""; stderr_result = ""; cmd = "dscl #{host} -#{args.join(' ')}"
|
27
|
+
status = popen4(cmd) do |pid, stdin, stdout, stderr|
|
28
|
+
stdout.each { |line| stdout_result << line }
|
29
|
+
stderr.each { |line| stderr_result << line }
|
30
|
+
end
|
31
|
+
return [cmd, status, stdout_result, stderr_result]
|
32
|
+
end
|
33
|
+
|
34
|
+
def safe_dscl(*args)
|
35
|
+
result = dscl(*args)
|
36
|
+
return "" if ( args.first =~ /^delete/ ) && ( result[1].exitstatus != 0 )
|
37
|
+
raise(Chef::Exceptions::Group,"dscl error: #{result.inspect}") unless result[1].exitstatus == 0
|
38
|
+
raise(Chef::Exceptions::Group,"dscl error: #{result.inspect}") if result[2] =~ /No such key: /
|
39
|
+
return result[2]
|
40
|
+
end
|
41
|
+
|
42
|
+
# This is handled in providers/group.rb by Etc.getgrnam()
|
43
|
+
# def group_exists?(group)
|
44
|
+
# groups = safe_dscl("list /Groups")
|
45
|
+
# !! ( groups =~ Regexp.new("\n#{group}\n") )
|
46
|
+
# end
|
47
|
+
|
48
|
+
# get a free GID greater than 200
|
49
|
+
def get_free_gid(search_limit=1000)
|
50
|
+
gid = nil; next_gid_guess = 200
|
51
|
+
groups_gids = safe_dscl("list /Groups gid")
|
52
|
+
while(next_gid_guess < search_limit + 200)
|
53
|
+
if groups_gids =~ Regexp.new("#{next_gid_guess}\n")
|
54
|
+
next_gid_guess += 1
|
55
|
+
else
|
56
|
+
gid = next_gid_guess
|
57
|
+
break
|
58
|
+
end
|
59
|
+
end
|
60
|
+
return gid || raise("gid not found. Exhausted. Searched #{search_limit} times")
|
61
|
+
end
|
62
|
+
|
63
|
+
def gid_used?(gid)
|
64
|
+
return false unless gid
|
65
|
+
groups_gids = safe_dscl("list /Groups gid")
|
66
|
+
!! ( groups_gids =~ Regexp.new("#{gid}\n") )
|
67
|
+
end
|
68
|
+
|
69
|
+
def set_gid
|
70
|
+
@new_resource.gid(get_free_gid) if [nil,""].include? @new_resource.gid
|
71
|
+
raise(Chef::Exceptions::Group,"gid is already in use") if gid_used?(@new_resource.gid)
|
72
|
+
safe_dscl("create /Groups/#{@new_resource.group_name} PrimaryGroupID #{@new_resource.gid}")
|
73
|
+
end
|
74
|
+
|
75
|
+
def set_members
|
76
|
+
unless @new_resource.append
|
77
|
+
Chef::Log.debug("#{@new_resource}: removing group members #{@current_resource.members.join(' ')}") unless @current_resource.members.empty?
|
78
|
+
safe_dscl("create /Groups/#{@new_resource.group_name} GroupMembers") # clear guid list
|
79
|
+
safe_dscl("create /Groups/#{@new_resource.group_name} GroupMembership") # clear user list
|
80
|
+
end
|
81
|
+
Chef::Log.debug("#{@new_resource}: setting group members #{@new_resource.members.join(', ')}") unless @new_resource.members.empty?
|
82
|
+
safe_dscl("append /Groups/#{@new_resource.group_name} GroupMembership #{@new_resource.members.join(' ')}")
|
83
|
+
end
|
84
|
+
|
85
|
+
def load_current_resource
|
86
|
+
super
|
87
|
+
raise Chef::Exceptions::Group, "Could not find binary /usr/bin/dscl for #{@new_resource}" unless ::File.exists?("/usr/bin/dscl")
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_group
|
91
|
+
manage_group(false)
|
92
|
+
end
|
93
|
+
|
94
|
+
def manage_group(manage=true)#
|
95
|
+
fields = []
|
96
|
+
if manage
|
97
|
+
[:group_name,:gid,:members].each do |field|
|
98
|
+
if @current_resource.send(field) != @new_resource.send(field)
|
99
|
+
fields << field if @new_resource.send(field)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
else
|
103
|
+
# create
|
104
|
+
fields = [:group_name,:gid,:members]
|
105
|
+
end
|
106
|
+
|
107
|
+
fields.each do |field|
|
108
|
+
case field
|
109
|
+
when :group_name
|
110
|
+
safe_dscl("create /Groups/#{@new_resource.group_name}")
|
111
|
+
safe_dscl("create /Groups/#{@new_resource.group_name} Password '*'")
|
112
|
+
|
113
|
+
when :gid
|
114
|
+
set_gid
|
115
|
+
|
116
|
+
when :members
|
117
|
+
set_members
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def remove_group
|
123
|
+
safe_dscl("delete /Groups/#{@new_resource.group_name}")
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
attr_accessor :rest
|
26
26
|
|
27
27
|
def load_current_resource
|
28
|
-
@rest = Chef::REST.new(@new_resource.url)
|
28
|
+
@rest = Chef::REST.new(@new_resource.url, nil, nil)
|
29
29
|
end
|
30
30
|
|
31
31
|
# Send a GET request to @new_resource.url, with ?message=@new_resource.message
|
@@ -34,6 +34,7 @@ class Chef
|
|
34
34
|
body = @rest.run_request(
|
35
35
|
:GET,
|
36
36
|
@rest.create_url("#{@new_resource.url}?message=#{message}"),
|
37
|
+
{},
|
37
38
|
false,
|
38
39
|
10,
|
39
40
|
false
|
@@ -49,6 +50,7 @@ class Chef
|
|
49
50
|
body = @rest.run_request(
|
50
51
|
:PUT,
|
51
52
|
@rest.create_url("#{@new_resource.url}"),
|
53
|
+
{},
|
52
54
|
message,
|
53
55
|
10,
|
54
56
|
false
|
@@ -64,6 +66,7 @@ class Chef
|
|
64
66
|
body = @rest.run_request(
|
65
67
|
:POST,
|
66
68
|
@rest.create_url("#{@new_resource.url}"),
|
69
|
+
{},
|
67
70
|
message,
|
68
71
|
10,
|
69
72
|
false
|
@@ -78,6 +81,7 @@ class Chef
|
|
78
81
|
body = @rest.run_request(
|
79
82
|
:DELETE,
|
80
83
|
@rest.create_url("#{@new_resource.url}"),
|
84
|
+
{},
|
81
85
|
false,
|
82
86
|
10,
|
83
87
|
false
|
@@ -99,4 +103,4 @@ class Chef
|
|
99
103
|
|
100
104
|
end
|
101
105
|
end
|
102
|
-
end
|
106
|
+
end
|
data/lib/chef/provider/link.rb
CHANGED
@@ -114,7 +114,7 @@ class Chef
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def action_create
|
117
|
-
if @current_resource.to != @new_resource.to
|
117
|
+
if @current_resource.to != ::File.expand_path(@new_resource.to, @new_resource.target_file)
|
118
118
|
Chef::Log.info("Creating a #{@new_resource.link_type} link from #{@new_resource.to} -> #{@new_resource.target_file} for #{@new_resource}")
|
119
119
|
if @new_resource.link_type == :symbolic
|
120
120
|
run_command(
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Cary Penniman (<cary@rightscale.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
|
+
class Chef
|
20
|
+
|
21
|
+
class Provider
|
22
|
+
|
23
|
+
class Log
|
24
|
+
|
25
|
+
# Chef log provider, allows logging to chef's logs from recipes
|
26
|
+
class ChefLog < Chef::Provider
|
27
|
+
|
28
|
+
# No concept of a 'current' resource for logs, this is a no-op
|
29
|
+
#
|
30
|
+
# === Return
|
31
|
+
# true:: Always return true
|
32
|
+
def load_current_resource
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
# Write the log to Chef's log
|
37
|
+
#
|
38
|
+
# === Return
|
39
|
+
# true:: Always return true
|
40
|
+
def action_write
|
41
|
+
Chef::Log.send(@new_resource.level, @new_resource.name)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Joe Williams (<joe@joetify.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Joe Williams
|
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/log'
|
20
|
+
require 'chef/mixin/command'
|
21
|
+
require 'chef/provider'
|
22
|
+
|
23
|
+
class Chef
|
24
|
+
class Provider
|
25
|
+
class Mdadm < Chef::Provider
|
26
|
+
|
27
|
+
include Chef::Mixin::Command
|
28
|
+
|
29
|
+
def initialize(node, new_resource)
|
30
|
+
super(node, new_resource)
|
31
|
+
end
|
32
|
+
|
33
|
+
def load_current_resource
|
34
|
+
@current_resource = Chef::Resource::Mdadm.new(@new_resource.name)
|
35
|
+
@current_resource.raid_device(@new_resource.raid_device)
|
36
|
+
Chef::Log.debug("Checking for software raid device #{@current_resource.raid_device}")
|
37
|
+
|
38
|
+
command = "mdadm --detail --scan"
|
39
|
+
exists = false
|
40
|
+
status = popen4(command) do |pid, stdin, stdout, stderr|
|
41
|
+
stdout.each do |line|
|
42
|
+
if line.include? @new_resource.raid_device
|
43
|
+
exists = true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
@current_resource.exists(exists)
|
48
|
+
end
|
49
|
+
|
50
|
+
def action_create
|
51
|
+
unless @current_resource.exists
|
52
|
+
command = "yes | mdadm --create #{@new_resource.raid_device} --chunk=#{@new_resource.chunk} --level #{@new_resource.level} --raid-devices #{@new_resource.devices.length} #{@new_resource.devices.collect{|x| x + " "}.to_s.chop}"
|
53
|
+
Chef::Log.debug("mdadm command: #{command}")
|
54
|
+
pid, stdin, stdout, stderr = popen4(command)
|
55
|
+
Chef::Log.info("Created mdadm raid device (#{@new_resource.raid_device})")
|
56
|
+
@new_resource.updated = true
|
57
|
+
else
|
58
|
+
Chef::Log.debug("mdadm raid device already exists (#{@new_resource.raid_device})")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def action_assemble
|
63
|
+
unless @current_resource.exists
|
64
|
+
command = "yes | mdadm --assemble #{@new_resource.raid_device} #{@new_resource.devices.collect{|x| x + " "}.to_s.chop}"
|
65
|
+
Chef::Log.debug("mdadm command: #{command}")
|
66
|
+
pid, stdin, stdout, stderr = popen4(command)
|
67
|
+
Chef::Log.info("Assembled mdadm raid device (#{@new_resource.raid_device})")
|
68
|
+
@new_resource.updated = true
|
69
|
+
else
|
70
|
+
Chef::Log.debug("mdadm raid device already exists (#{@new_resource.raid_device})")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def action_stop
|
75
|
+
if @current_resource.exists
|
76
|
+
command = "yes | mdadm --stop #{@new_resource.raid_device}"
|
77
|
+
Chef::Log.debug("mdadm command: #{command}")
|
78
|
+
pid, stdin, stdout, stderr = popen4(command)
|
79
|
+
Chef::Log.info("Stopped mdadm raid device (#{@new_resource.raid_device})")
|
80
|
+
@new_resource.updated = true
|
81
|
+
else
|
82
|
+
Chef::Log.debug("mdadm raid device doesn't exist (#{@new_resource.raid_device})")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|