chef 0.9.18 → 0.10.0.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -3
- data/distro/arch/etc/rc.d/chef-server +0 -4
- data/distro/arch/etc/rc.d/chef-server-webui +0 -4
- data/distro/arch/etc/rc.d/chef-solr +0 -4
- data/distro/arch/etc/rc.d/chef-solr-indexer +0 -4
- data/lib/chef.rb +3 -3
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +11 -1
- data/lib/chef/application/client.rb +18 -22
- data/lib/chef/application/knife.rb +28 -29
- data/lib/chef/application/solo.rb +14 -12
- data/lib/chef/client.rb +112 -54
- data/lib/chef/config.rb +4 -0
- data/lib/chef/cookbook/chefignore.rb +66 -0
- data/lib/chef/cookbook/cookbook_collection.rb +6 -5
- data/lib/chef/cookbook/cookbook_version_loader.rb +151 -0
- data/lib/chef/cookbook/file_system_file_vendor.rb +10 -8
- data/lib/chef/cookbook/metadata.rb +200 -108
- data/lib/chef/cookbook_loader.rb +39 -163
- data/lib/chef/cookbook_uploader.rb +100 -78
- data/lib/chef/cookbook_version.rb +92 -47
- data/lib/chef/cookbook_version_selector.rb +163 -0
- data/lib/chef/couchdb.rb +9 -1
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item.rb +126 -0
- data/lib/chef/environment.rb +386 -0
- data/lib/chef/exceptions.rb +82 -1
- data/lib/chef/index_queue/amqp_client.rb +15 -12
- data/lib/chef/index_queue/indexable.rb +38 -4
- data/lib/chef/json_compat.rb +3 -3
- data/lib/chef/knife.rb +97 -202
- data/lib/chef/knife/bootstrap.rb +27 -61
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +4 -2
- data/lib/chef/knife/bootstrap/centos5-gems.erb +6 -15
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +3 -4
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +6 -5
- data/lib/chef/knife/client_bulk_delete.rb +6 -3
- data/lib/chef/knife/client_create.rb +13 -10
- data/lib/chef/knife/client_delete.rb +10 -7
- data/lib/chef/knife/client_edit.rb +9 -6
- data/lib/chef/knife/client_list.rb +8 -5
- data/lib/chef/knife/client_reregister.rb +9 -6
- data/lib/chef/knife/client_show.rb +9 -6
- data/lib/chef/knife/configure.rb +15 -19
- data/lib/chef/knife/configure_client.rb +4 -4
- data/lib/chef/knife/cookbook_bulk_delete.rb +11 -8
- data/lib/chef/knife/cookbook_create.rb +120 -55
- data/lib/chef/knife/cookbook_delete.rb +18 -12
- data/lib/chef/knife/cookbook_download.rb +10 -6
- data/lib/chef/knife/cookbook_list.rb +15 -6
- data/lib/chef/knife/cookbook_metadata.rb +41 -21
- data/lib/chef/knife/cookbook_metadata_from_file.rb +4 -0
- data/lib/chef/knife/cookbook_show.rb +16 -5
- data/lib/chef/knife/cookbook_site_download.rb +2 -2
- data/lib/chef/knife/cookbook_site_share.rb +18 -13
- data/lib/chef/knife/cookbook_site_unshare.rb +7 -4
- data/lib/chef/knife/cookbook_site_vendor.rb +21 -18
- data/lib/chef/knife/cookbook_test.rb +14 -14
- data/lib/chef/knife/cookbook_upload.rb +91 -40
- data/lib/chef/knife/data_bag_create.rb +41 -6
- data/lib/chef/knife/data_bag_delete.rb +5 -3
- data/lib/chef/knife/data_bag_edit.rb +55 -11
- data/lib/chef/knife/data_bag_from_file.rb +47 -7
- data/lib/chef/knife/data_bag_list.rb +4 -1
- data/lib/chef/knife/data_bag_show.rb +44 -4
- data/lib/chef/knife/environment_create.rb +53 -0
- data/lib/chef/knife/environment_delete.rb +45 -0
- data/lib/chef/knife/environment_edit.rb +45 -0
- data/lib/chef/knife/environment_from_file.rb +39 -0
- data/lib/chef/knife/environment_list.rb +42 -0
- data/lib/chef/knife/environment_show.rb +46 -0
- data/lib/chef/knife/exec.rb +1 -1
- data/lib/chef/knife/index_rebuild.rb +8 -9
- data/lib/chef/knife/node_bulk_delete.rb +9 -6
- data/lib/chef/knife/node_create.rb +9 -6
- data/lib/chef/knife/node_delete.rb +10 -7
- data/lib/chef/knife/node_edit.rb +129 -10
- data/lib/chef/knife/node_from_file.rb +10 -7
- data/lib/chef/knife/node_list.rb +11 -6
- data/lib/chef/knife/node_run_list_add.rb +10 -7
- data/lib/chef/knife/node_run_list_remove.rb +9 -6
- data/lib/chef/knife/node_show.rb +15 -7
- data/lib/chef/knife/recipe_list.rb +4 -3
- data/lib/chef/knife/role_bulk_delete.rb +9 -6
- data/lib/chef/knife/role_create.rb +9 -6
- data/lib/chef/knife/role_delete.rb +10 -7
- data/lib/chef/knife/role_edit.rb +11 -8
- data/lib/chef/knife/role_from_file.rb +10 -7
- data/lib/chef/knife/role_list.rb +8 -5
- data/lib/chef/knife/role_show.rb +11 -8
- data/lib/chef/knife/search.rb +33 -10
- data/lib/chef/knife/ssh.rb +33 -61
- data/lib/chef/knife/status.rb +7 -4
- data/lib/chef/knife/subcommand_loader.rb +101 -0
- data/lib/chef/knife/tag_create.rb +31 -0
- data/lib/chef/knife/tag_delete.rb +31 -0
- data/lib/chef/knife/tag_list.rb +29 -0
- data/lib/chef/knife/ui.rb +229 -0
- data/lib/chef/knife/windows_bootstrap.rb +8 -5
- data/lib/chef/log.rb +5 -59
- data/lib/chef/mash.rb +211 -0
- data/lib/chef/mixins.rb +1 -2
- data/lib/chef/nil_argument.rb +3 -0
- data/lib/chef/node.rb +96 -34
- data/lib/chef/platform.rb +27 -0
- data/lib/chef/provider/cookbook_file.rb +21 -20
- data/lib/chef/provider/deploy/revision.rb +3 -0
- data/lib/chef/provider/file.rb +20 -11
- data/lib/chef/provider/git.rb +26 -26
- data/lib/chef/provider/group/aix.rb +70 -0
- data/lib/chef/provider/group/groupadd.rb +7 -4
- data/lib/chef/provider/group/usermod.rb +1 -1
- data/lib/chef/provider/package.rb +28 -28
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/portage.rb +50 -39
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +3 -20
- data/lib/chef/provider/remote_directory.rb +0 -2
- data/lib/chef/provider/remote_file.rb +2 -3
- data/lib/chef/provider/service/arch.rb +28 -35
- data/lib/chef/provider/service/simple.rb +1 -1
- data/lib/chef/provider/subversion.rb +22 -22
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/recipe.rb +10 -12
- data/lib/chef/resource.rb +49 -42
- data/lib/chef/resource/gem_package.rb +7 -3
- data/lib/chef/resource/git.rb +5 -5
- data/lib/chef/resource/package.rb +7 -7
- data/lib/chef/resource/scm.rb +2 -1
- data/lib/chef/resource/solaris_package.rb +0 -1
- data/lib/chef/resource/yum_package.rb +0 -1
- data/lib/chef/rest.rb +7 -16
- data/lib/chef/rest/rest_request.rb +0 -16
- data/lib/chef/role.rb +67 -13
- data/lib/chef/run_context.rb +37 -21
- data/lib/chef/run_list.rb +30 -15
- data/lib/chef/run_list/run_list_expansion.rb +41 -20
- data/lib/chef/run_list/run_list_item.rb +20 -6
- data/lib/chef/run_list/versioned_recipe_list.rb +68 -0
- data/lib/chef/runner.rb +7 -15
- data/lib/chef/search/query.rb +12 -7
- data/lib/chef/shef.rb +6 -7
- data/lib/chef/shef/shef_session.rb +40 -35
- data/lib/chef/shell_out.rb +22 -201
- data/lib/chef/shell_out/unix.rb +224 -0
- data/lib/chef/shell_out/windows.rb +95 -0
- data/lib/chef/solr_query.rb +187 -0
- data/lib/chef/solr_query/lucene.treetop +145 -0
- data/lib/chef/solr_query/lucene_nodes.rb +285 -0
- data/lib/chef/solr_query/query_transform.rb +65 -0
- data/lib/chef/solr_query/solr_http_request.rb +118 -0
- data/lib/chef/version.rb +4 -2
- data/lib/chef/version_class.rb +70 -0
- data/lib/chef/version_constraint.rb +116 -0
- metadata +68 -37
- data/lib/chef/cookbook/metadata/version.rb +0 -87
- data/lib/chef/knife/bluebox_images_list.rb +0 -54
- data/lib/chef/knife/bluebox_server_create.rb +0 -157
- data/lib/chef/knife/bluebox_server_delete.rb +0 -63
- data/lib/chef/knife/bluebox_server_list.rb +0 -59
- data/lib/chef/knife/ec2_instance_data.rb +0 -46
- data/lib/chef/knife/ec2_server_create.rb +0 -218
- data/lib/chef/knife/ec2_server_delete.rb +0 -87
- data/lib/chef/knife/ec2_server_list.rb +0 -89
- data/lib/chef/knife/rackspace_server_create.rb +0 -184
- data/lib/chef/knife/rackspace_server_delete.rb +0 -57
- data/lib/chef/knife/rackspace_server_list.rb +0 -59
- data/lib/chef/knife/slicehost_images_list.rb +0 -53
- data/lib/chef/knife/slicehost_server_create.rb +0 -103
- data/lib/chef/knife/slicehost_server_delete.rb +0 -61
- data/lib/chef/knife/slicehost_server_list.rb +0 -64
- data/lib/chef/knife/terremark_server_create.rb +0 -152
- data/lib/chef/knife/terremark_server_delete.rb +0 -87
- data/lib/chef/knife/terremark_server_list.rb +0 -77
- data/lib/chef/mixin/find_preferred_file.rb +0 -92
data/lib/chef/platform.rb
CHANGED
@@ -47,6 +47,13 @@ class Chef
|
|
47
47
|
:group => Chef::Provider::Group::Dscl
|
48
48
|
}
|
49
49
|
},
|
50
|
+
:mac_os_x_server => {
|
51
|
+
:default => {
|
52
|
+
:package => Chef::Provider::Package::Macports,
|
53
|
+
:user => Chef::Provider::User::Dscl,
|
54
|
+
:group => Chef::Provider::Group::Dscl
|
55
|
+
}
|
56
|
+
},
|
50
57
|
:freebsd => {
|
51
58
|
:default => {
|
52
59
|
:group => Chef::Provider::Group::Pw,
|
@@ -182,6 +189,26 @@ class Chef
|
|
182
189
|
:group => Chef::Provider::Group::Usermod
|
183
190
|
}
|
184
191
|
},
|
192
|
+
:netbsd => {
|
193
|
+
:default => {
|
194
|
+
:group => Chef::Provider::Group::Usermod
|
195
|
+
}
|
196
|
+
},
|
197
|
+
:openbsd => {
|
198
|
+
:default => {
|
199
|
+
:group => Chef::Provider::Group::Usermod
|
200
|
+
}
|
201
|
+
},
|
202
|
+
:hpux => {
|
203
|
+
:default => {
|
204
|
+
:group => Chef::Provider::Group::Usermod
|
205
|
+
}
|
206
|
+
},
|
207
|
+
:aix => {
|
208
|
+
:default => {
|
209
|
+
:group => Chef::Provider::Group::Aix
|
210
|
+
}
|
211
|
+
},
|
185
212
|
:default => {
|
186
213
|
:file => Chef::Provider::File,
|
187
214
|
:directory => Chef::Provider::Directory,
|
@@ -23,7 +23,7 @@ require 'tempfile'
|
|
23
23
|
class Chef
|
24
24
|
class Provider
|
25
25
|
class CookbookFile < Chef::Provider::File
|
26
|
-
|
26
|
+
|
27
27
|
def load_current_resource
|
28
28
|
@current_resource = Chef::Resource::CookbookFile.new(@new_resource.name)
|
29
29
|
@new_resource.path.gsub!(/\\/, "/") # for Windows
|
@@ -33,21 +33,22 @@ class Chef
|
|
33
33
|
|
34
34
|
|
35
35
|
def action_create
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
36
|
+
assert_enclosing_directory_exists!
|
37
|
+
if file_cache_location && content_stale?
|
38
|
+
Chef::Log.debug("content of file #{@new_resource.path} requires update")
|
39
|
+
backup_new_resource
|
40
|
+
Tempfile.open(::File.basename(@new_resource.name)) do |staging_file|
|
41
|
+
Chef::Log.debug("staging #{file_cache_location} to #{staging_file.path}")
|
42
|
+
staging_file.close
|
43
|
+
stage_file_to_tmpdir(staging_file.path)
|
44
|
+
FileUtils.mv(staging_file.path, @new_resource.path)
|
45
|
+
end
|
46
|
+
@new_resource.updated_by_last_action(true)
|
47
|
+
else
|
48
|
+
set_all_access_controls(@new_resource.path)
|
49
|
+
end
|
50
|
+
@new_resource.updated_by_last_action?
|
51
|
+
end
|
51
52
|
|
52
53
|
def action_create_if_missing
|
53
54
|
if ::File.exists?(@new_resource.path)
|
@@ -56,21 +57,21 @@ class Chef
|
|
56
57
|
action_create
|
57
58
|
end
|
58
59
|
end
|
59
|
-
|
60
|
+
|
60
61
|
def file_cache_location
|
61
62
|
@file_cache_location ||= begin
|
62
63
|
cookbook = run_context.cookbook_collection[resource_cookbook]
|
63
64
|
cookbook.preferred_filename_on_disk_location(node, :files, @new_resource.source, @new_resource.path)
|
64
65
|
end
|
65
66
|
end
|
66
|
-
|
67
|
-
# Determine the cookbook to get the file from. If new resource sets an
|
67
|
+
|
68
|
+
# Determine the cookbook to get the file from. If new resource sets an
|
68
69
|
# explicit cookbook, use it, otherwise fall back to the implicit cookbook
|
69
70
|
# i.e., the cookbook the resource was declared in.
|
70
71
|
def resource_cookbook
|
71
72
|
@new_resource.cookbook || @new_resource.cookbook_name
|
72
73
|
end
|
73
|
-
|
74
|
+
|
74
75
|
# Copy the file from the cookbook cache to a temporary location and then
|
75
76
|
# set its file access control settings.
|
76
77
|
def stage_file_to_tmpdir(staging_file_location)
|
@@ -1,6 +1,9 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
|
+
# Author:: Tim Hinderliter (<tim@opscode.com>)
|
4
|
+
# Author:: Seth Falcon (<seth@opscode.com>)
|
3
5
|
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
6
|
+
# Copyright:: Copyright (c) 2010 Opscode, Inc.
|
4
7
|
# License:: Apache License, Version 2.0
|
5
8
|
#
|
6
9
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/chef/provider/file.rb
CHANGED
@@ -75,12 +75,12 @@ class Chef
|
|
75
75
|
return false if @new_resource.owner.nil?
|
76
76
|
|
77
77
|
@set_user_id = case @new_resource.owner
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
when /^\d+$/, Integer
|
79
|
+
@new_resource.owner.to_i
|
80
|
+
else
|
81
|
+
# This raises an ArgumentError if you can't find the user
|
82
|
+
Etc.getpwnam(@new_resource.owner).uid
|
83
|
+
end
|
84
84
|
|
85
85
|
@set_user_id == @current_resource.owner
|
86
86
|
end
|
@@ -100,11 +100,11 @@ class Chef
|
|
100
100
|
return false if @new_resource.group.nil?
|
101
101
|
|
102
102
|
@set_group_id = case @new_resource.group
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
when /^\d+$/, Integer
|
104
|
+
@new_resource.group.to_i
|
105
|
+
else
|
106
|
+
Etc.getgrnam(@new_resource.group).gid
|
107
|
+
end
|
108
108
|
|
109
109
|
@set_group_id == @current_resource.group
|
110
110
|
end
|
@@ -137,6 +137,7 @@ class Chef
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def action_create
|
140
|
+
assert_enclosing_directory_exists!
|
140
141
|
unless ::File.exists?(@new_resource.path)
|
141
142
|
Chef::Log.info("Creating #{@new_resource} at #{@new_resource.path}")
|
142
143
|
::File.open(@new_resource.path, "w+") {|f| f.write @new_resource.content }
|
@@ -205,6 +206,14 @@ class Chef
|
|
205
206
|
|
206
207
|
private
|
207
208
|
|
209
|
+
def assert_enclosing_directory_exists!
|
210
|
+
enclosing_dir = ::File.dirname(@new_resource.path)
|
211
|
+
unless ::File.directory?(enclosing_dir)
|
212
|
+
msg = "Cannot create a file at #{@new_resource.path} because the enclosing directory (#{enclosing_dir}) does not exist"
|
213
|
+
raise Chef::Exceptions::EnclosingDirectoryDoesNotExist, msg
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
208
217
|
def new_resource_content_checksum
|
209
218
|
@new_resource.content && Digest::SHA2.hexdigest(@new_resource.content)
|
210
219
|
end
|
data/lib/chef/provider/git.rb
CHANGED
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -25,16 +25,16 @@ require 'fileutils'
|
|
25
25
|
class Chef
|
26
26
|
class Provider
|
27
27
|
class Git < Chef::Provider
|
28
|
-
|
28
|
+
|
29
29
|
include Chef::Mixin::Command
|
30
|
-
|
30
|
+
|
31
31
|
def load_current_resource
|
32
32
|
@current_resource = Chef::Resource::Git.new(@new_resource.name)
|
33
33
|
if current_revision = find_current_revision
|
34
34
|
@current_resource.revision current_revision
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def action_checkout
|
39
39
|
assert_target_directory_valid!
|
40
40
|
|
@@ -47,13 +47,13 @@ class Chef
|
|
47
47
|
Chef::Log.info "Taking no action, checkout destination #{@new_resource.destination} already exists or is a non-empty directory"
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def action_export
|
52
52
|
action_checkout
|
53
53
|
FileUtils.rm_rf(::File.join(@new_resource.destination,".git"))
|
54
54
|
@new_resource.updated_by_last_action(true)
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def action_sync
|
58
58
|
assert_target_directory_valid!
|
59
59
|
|
@@ -92,7 +92,7 @@ class Chef
|
|
92
92
|
def find_current_revision
|
93
93
|
if ::File.exist?(::File.join(cwd, ".git"))
|
94
94
|
status, result, error_message = output_of_command("git rev-parse HEAD", run_options(:cwd=>cwd))
|
95
|
-
|
95
|
+
|
96
96
|
# 128 is returned when we're not in a git repo. this is fine
|
97
97
|
unless [0,128].include?(status.exitstatus)
|
98
98
|
handle_command_failures(status, "STDOUT: #{result}\nSTDERR: #{error_message}")
|
@@ -100,27 +100,27 @@ class Chef
|
|
100
100
|
end
|
101
101
|
sha_hash?(result) ? result : nil
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
def clone
|
105
105
|
remote = @new_resource.remote
|
106
106
|
|
107
107
|
args = []
|
108
108
|
args << "-o #{remote}" unless remote == 'origin'
|
109
109
|
args << "--depth #{@new_resource.depth}" if @new_resource.depth
|
110
|
-
|
110
|
+
|
111
111
|
Chef::Log.info "Cloning repo #{@new_resource.repository} to #{@new_resource.destination}"
|
112
|
-
|
112
|
+
|
113
113
|
clone_cmd = "git clone #{args.join(' ')} #{@new_resource.repository} #{@new_resource.destination}"
|
114
114
|
run_command(run_options(:command => clone_cmd))
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
def checkout
|
118
118
|
sha_ref = target_revision
|
119
119
|
Chef::Log.info "Checking out branch: #{@new_resource.revision} reference: #{sha_ref}"
|
120
120
|
# checkout into a local branch rather than a detached HEAD
|
121
121
|
run_command(run_options(:command => "git checkout -b deploy #{sha_ref}", :cwd => @new_resource.destination))
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
def enable_submodules
|
125
125
|
if @new_resource.enable_submodules
|
126
126
|
Chef::Log.info "Enabling git submodules"
|
@@ -128,7 +128,7 @@ class Chef
|
|
128
128
|
run_command(run_options(:command => command, :cwd => @new_resource.destination))
|
129
129
|
end
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
def fetch_updates
|
133
133
|
setup_remote_tracking_branches if @new_resource.remote != 'origin'
|
134
134
|
|
@@ -161,18 +161,18 @@ class Chef
|
|
161
161
|
def target_revision
|
162
162
|
@target_revision ||= begin
|
163
163
|
assert_revision_not_remote
|
164
|
-
|
164
|
+
|
165
165
|
if sha_hash?(@new_resource.revision)
|
166
|
-
@target_revision = @new_resource.revision
|
166
|
+
@target_revision = @new_resource.revision
|
167
167
|
else
|
168
168
|
resolved_reference = remote_resolve_reference
|
169
169
|
@target_revision = extract_revision(resolved_reference)
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
173
|
-
|
173
|
+
|
174
174
|
alias :revision_slug :target_revision
|
175
|
-
|
175
|
+
|
176
176
|
def remote_resolve_reference
|
177
177
|
command = git('ls-remote', @new_resource.repository, @new_resource.revision)
|
178
178
|
Chef::Log.debug("Executing #{command}")
|
@@ -187,20 +187,20 @@ class Chef
|
|
187
187
|
end
|
188
188
|
result
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
private
|
192
|
-
|
192
|
+
|
193
193
|
def run_options(run_opts={})
|
194
194
|
run_opts[:user] = @new_resource.user if @new_resource.user
|
195
195
|
run_opts[:group] = @new_resource.group if @new_resource.group
|
196
196
|
run_opts[:environment] = {"GIT_SSH" => @new_resource.ssh_wrapper} if @new_resource.ssh_wrapper
|
197
197
|
run_opts
|
198
198
|
end
|
199
|
-
|
199
|
+
|
200
200
|
def cwd
|
201
201
|
@new_resource.destination
|
202
202
|
end
|
203
|
-
|
203
|
+
|
204
204
|
def git(*args)
|
205
205
|
["git", *args].compact.join(" ")
|
206
206
|
end
|
@@ -208,18 +208,18 @@ class Chef
|
|
208
208
|
def sha_hash?(string)
|
209
209
|
string =~ /^[0-9a-f]{40}$/
|
210
210
|
end
|
211
|
-
|
211
|
+
|
212
212
|
def assert_revision_not_remote
|
213
213
|
if @new_resource.revision =~ /^origin\//
|
214
214
|
reference = @new_resource.revision
|
215
215
|
error_text = "Deploying remote branches is not supported. " +
|
216
216
|
"Specify the remote branch as a local branch for " +
|
217
|
-
"the git repository you're deploying from " +
|
217
|
+
"the git repository you're deploying from " +
|
218
218
|
"(ie: '#{reference.gsub('origin/', '')}' rather than '#{reference}')."
|
219
219
|
raise RuntimeError, error_text
|
220
220
|
end
|
221
221
|
end
|
222
|
-
|
222
|
+
|
223
223
|
def extract_revision(resolved_reference)
|
224
224
|
unless resolved_reference =~ /^([0-9a-f]{40})\s+(\S+)/
|
225
225
|
msg = "Unable to parse SHA reference for '#{@new_resource.revision}' in repository '#{@new_resource.repository}'. "
|
@@ -229,7 +229,7 @@ class Chef
|
|
229
229
|
end
|
230
230
|
$1
|
231
231
|
end
|
232
|
-
|
232
|
+
|
233
233
|
end
|
234
234
|
end
|
235
235
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
3
|
+
# Copyright:: Copyright (c) 2010 VMware, 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/group/usermod'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Provider
|
23
|
+
class Group
|
24
|
+
class Aix < Chef::Provider::Group::Usermod
|
25
|
+
|
26
|
+
def required_binaries
|
27
|
+
[ "/usr/bin/mkgroup",
|
28
|
+
"/usr/bin/chgroup",
|
29
|
+
"/usr/sbin/rmgroup" ]
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_group
|
33
|
+
command = "mkgroup"
|
34
|
+
command << set_options << " #{@new_resource.group_name}"
|
35
|
+
run_command(:command => command)
|
36
|
+
modify_group_members
|
37
|
+
end
|
38
|
+
|
39
|
+
def manage_group
|
40
|
+
command = "chgroup"
|
41
|
+
options = set_options
|
42
|
+
#Usage: chgroup [-R load_module] "attr=value" ... group
|
43
|
+
if options.size > 0
|
44
|
+
command << options << " #{@new_resource.group_name}"
|
45
|
+
run_command(:command => command)
|
46
|
+
end
|
47
|
+
modify_group_members
|
48
|
+
end
|
49
|
+
|
50
|
+
def remove_group
|
51
|
+
run_command(:command => "rmgroup #{@new_resource.group_name}")
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_options
|
55
|
+
opts = ""
|
56
|
+
{ :gid => "id" }.sort { |a,b| a[0] <=> b[0] }.each do |field, option|
|
57
|
+
if @current_resource.send(field) != @new_resource.send(field)
|
58
|
+
if @new_resource.send(field)
|
59
|
+
Chef::Log.debug("#{@new_resource}: setting #{field.to_s} to #{@new_resource.send(field)}")
|
60
|
+
opts << " '#{option}=#{@new_resource.send(field)}'"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
opts
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -21,12 +21,15 @@ class Chef
|
|
21
21
|
class Group
|
22
22
|
class Groupadd < Chef::Provider::Group
|
23
23
|
|
24
|
-
def
|
25
|
-
super
|
26
|
-
|
24
|
+
def required_binaries
|
27
25
|
[ "/usr/sbin/groupadd",
|
28
26
|
"/usr/sbin/groupmod",
|
29
|
-
"/usr/sbin/groupdel" ]
|
27
|
+
"/usr/sbin/groupdel" ]
|
28
|
+
end
|
29
|
+
|
30
|
+
def load_current_resource
|
31
|
+
super
|
32
|
+
required_binaries.each do |required_binary|
|
30
33
|
raise Chef::Exceptions::Group, "Could not find binary #{required_binary} for #{@new_resource}" unless ::File.exists?(required_binary)
|
31
34
|
end
|
32
35
|
end
|