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.
Files changed (177) hide show
  1. data/README.rdoc +0 -3
  2. data/distro/arch/etc/rc.d/chef-server +0 -4
  3. data/distro/arch/etc/rc.d/chef-server-webui +0 -4
  4. data/distro/arch/etc/rc.d/chef-solr +0 -4
  5. data/distro/arch/etc/rc.d/chef-solr-indexer +0 -4
  6. data/lib/chef.rb +3 -3
  7. data/lib/chef/api_client.rb +1 -1
  8. data/lib/chef/application.rb +11 -1
  9. data/lib/chef/application/client.rb +18 -22
  10. data/lib/chef/application/knife.rb +28 -29
  11. data/lib/chef/application/solo.rb +14 -12
  12. data/lib/chef/client.rb +112 -54
  13. data/lib/chef/config.rb +4 -0
  14. data/lib/chef/cookbook/chefignore.rb +66 -0
  15. data/lib/chef/cookbook/cookbook_collection.rb +6 -5
  16. data/lib/chef/cookbook/cookbook_version_loader.rb +151 -0
  17. data/lib/chef/cookbook/file_system_file_vendor.rb +10 -8
  18. data/lib/chef/cookbook/metadata.rb +200 -108
  19. data/lib/chef/cookbook_loader.rb +39 -163
  20. data/lib/chef/cookbook_uploader.rb +100 -78
  21. data/lib/chef/cookbook_version.rb +92 -47
  22. data/lib/chef/cookbook_version_selector.rb +163 -0
  23. data/lib/chef/couchdb.rb +9 -1
  24. data/lib/chef/data_bag.rb +1 -1
  25. data/lib/chef/data_bag_item.rb +1 -1
  26. data/lib/chef/encrypted_data_bag_item.rb +126 -0
  27. data/lib/chef/environment.rb +386 -0
  28. data/lib/chef/exceptions.rb +82 -1
  29. data/lib/chef/index_queue/amqp_client.rb +15 -12
  30. data/lib/chef/index_queue/indexable.rb +38 -4
  31. data/lib/chef/json_compat.rb +3 -3
  32. data/lib/chef/knife.rb +97 -202
  33. data/lib/chef/knife/bootstrap.rb +27 -61
  34. data/lib/chef/knife/bootstrap/archlinux-gems.erb +4 -2
  35. data/lib/chef/knife/bootstrap/centos5-gems.erb +6 -15
  36. data/lib/chef/knife/bootstrap/fedora13-gems.erb +3 -4
  37. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
  38. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +6 -5
  39. data/lib/chef/knife/client_bulk_delete.rb +6 -3
  40. data/lib/chef/knife/client_create.rb +13 -10
  41. data/lib/chef/knife/client_delete.rb +10 -7
  42. data/lib/chef/knife/client_edit.rb +9 -6
  43. data/lib/chef/knife/client_list.rb +8 -5
  44. data/lib/chef/knife/client_reregister.rb +9 -6
  45. data/lib/chef/knife/client_show.rb +9 -6
  46. data/lib/chef/knife/configure.rb +15 -19
  47. data/lib/chef/knife/configure_client.rb +4 -4
  48. data/lib/chef/knife/cookbook_bulk_delete.rb +11 -8
  49. data/lib/chef/knife/cookbook_create.rb +120 -55
  50. data/lib/chef/knife/cookbook_delete.rb +18 -12
  51. data/lib/chef/knife/cookbook_download.rb +10 -6
  52. data/lib/chef/knife/cookbook_list.rb +15 -6
  53. data/lib/chef/knife/cookbook_metadata.rb +41 -21
  54. data/lib/chef/knife/cookbook_metadata_from_file.rb +4 -0
  55. data/lib/chef/knife/cookbook_show.rb +16 -5
  56. data/lib/chef/knife/cookbook_site_download.rb +2 -2
  57. data/lib/chef/knife/cookbook_site_share.rb +18 -13
  58. data/lib/chef/knife/cookbook_site_unshare.rb +7 -4
  59. data/lib/chef/knife/cookbook_site_vendor.rb +21 -18
  60. data/lib/chef/knife/cookbook_test.rb +14 -14
  61. data/lib/chef/knife/cookbook_upload.rb +91 -40
  62. data/lib/chef/knife/data_bag_create.rb +41 -6
  63. data/lib/chef/knife/data_bag_delete.rb +5 -3
  64. data/lib/chef/knife/data_bag_edit.rb +55 -11
  65. data/lib/chef/knife/data_bag_from_file.rb +47 -7
  66. data/lib/chef/knife/data_bag_list.rb +4 -1
  67. data/lib/chef/knife/data_bag_show.rb +44 -4
  68. data/lib/chef/knife/environment_create.rb +53 -0
  69. data/lib/chef/knife/environment_delete.rb +45 -0
  70. data/lib/chef/knife/environment_edit.rb +45 -0
  71. data/lib/chef/knife/environment_from_file.rb +39 -0
  72. data/lib/chef/knife/environment_list.rb +42 -0
  73. data/lib/chef/knife/environment_show.rb +46 -0
  74. data/lib/chef/knife/exec.rb +1 -1
  75. data/lib/chef/knife/index_rebuild.rb +8 -9
  76. data/lib/chef/knife/node_bulk_delete.rb +9 -6
  77. data/lib/chef/knife/node_create.rb +9 -6
  78. data/lib/chef/knife/node_delete.rb +10 -7
  79. data/lib/chef/knife/node_edit.rb +129 -10
  80. data/lib/chef/knife/node_from_file.rb +10 -7
  81. data/lib/chef/knife/node_list.rb +11 -6
  82. data/lib/chef/knife/node_run_list_add.rb +10 -7
  83. data/lib/chef/knife/node_run_list_remove.rb +9 -6
  84. data/lib/chef/knife/node_show.rb +15 -7
  85. data/lib/chef/knife/recipe_list.rb +4 -3
  86. data/lib/chef/knife/role_bulk_delete.rb +9 -6
  87. data/lib/chef/knife/role_create.rb +9 -6
  88. data/lib/chef/knife/role_delete.rb +10 -7
  89. data/lib/chef/knife/role_edit.rb +11 -8
  90. data/lib/chef/knife/role_from_file.rb +10 -7
  91. data/lib/chef/knife/role_list.rb +8 -5
  92. data/lib/chef/knife/role_show.rb +11 -8
  93. data/lib/chef/knife/search.rb +33 -10
  94. data/lib/chef/knife/ssh.rb +33 -61
  95. data/lib/chef/knife/status.rb +7 -4
  96. data/lib/chef/knife/subcommand_loader.rb +101 -0
  97. data/lib/chef/knife/tag_create.rb +31 -0
  98. data/lib/chef/knife/tag_delete.rb +31 -0
  99. data/lib/chef/knife/tag_list.rb +29 -0
  100. data/lib/chef/knife/ui.rb +229 -0
  101. data/lib/chef/knife/windows_bootstrap.rb +8 -5
  102. data/lib/chef/log.rb +5 -59
  103. data/lib/chef/mash.rb +211 -0
  104. data/lib/chef/mixins.rb +1 -2
  105. data/lib/chef/nil_argument.rb +3 -0
  106. data/lib/chef/node.rb +96 -34
  107. data/lib/chef/platform.rb +27 -0
  108. data/lib/chef/provider/cookbook_file.rb +21 -20
  109. data/lib/chef/provider/deploy/revision.rb +3 -0
  110. data/lib/chef/provider/file.rb +20 -11
  111. data/lib/chef/provider/git.rb +26 -26
  112. data/lib/chef/provider/group/aix.rb +70 -0
  113. data/lib/chef/provider/group/groupadd.rb +7 -4
  114. data/lib/chef/provider/group/usermod.rb +1 -1
  115. data/lib/chef/provider/package.rb +28 -28
  116. data/lib/chef/provider/package/dpkg.rb +1 -1
  117. data/lib/chef/provider/package/portage.rb +50 -39
  118. data/lib/chef/provider/package/rubygems.rb +1 -1
  119. data/lib/chef/provider/package/zypper.rb +3 -20
  120. data/lib/chef/provider/remote_directory.rb +0 -2
  121. data/lib/chef/provider/remote_file.rb +2 -3
  122. data/lib/chef/provider/service/arch.rb +28 -35
  123. data/lib/chef/provider/service/simple.rb +1 -1
  124. data/lib/chef/provider/subversion.rb +22 -22
  125. data/lib/chef/providers.rb +1 -0
  126. data/lib/chef/recipe.rb +10 -12
  127. data/lib/chef/resource.rb +49 -42
  128. data/lib/chef/resource/gem_package.rb +7 -3
  129. data/lib/chef/resource/git.rb +5 -5
  130. data/lib/chef/resource/package.rb +7 -7
  131. data/lib/chef/resource/scm.rb +2 -1
  132. data/lib/chef/resource/solaris_package.rb +0 -1
  133. data/lib/chef/resource/yum_package.rb +0 -1
  134. data/lib/chef/rest.rb +7 -16
  135. data/lib/chef/rest/rest_request.rb +0 -16
  136. data/lib/chef/role.rb +67 -13
  137. data/lib/chef/run_context.rb +37 -21
  138. data/lib/chef/run_list.rb +30 -15
  139. data/lib/chef/run_list/run_list_expansion.rb +41 -20
  140. data/lib/chef/run_list/run_list_item.rb +20 -6
  141. data/lib/chef/run_list/versioned_recipe_list.rb +68 -0
  142. data/lib/chef/runner.rb +7 -15
  143. data/lib/chef/search/query.rb +12 -7
  144. data/lib/chef/shef.rb +6 -7
  145. data/lib/chef/shef/shef_session.rb +40 -35
  146. data/lib/chef/shell_out.rb +22 -201
  147. data/lib/chef/shell_out/unix.rb +224 -0
  148. data/lib/chef/shell_out/windows.rb +95 -0
  149. data/lib/chef/solr_query.rb +187 -0
  150. data/lib/chef/solr_query/lucene.treetop +145 -0
  151. data/lib/chef/solr_query/lucene_nodes.rb +285 -0
  152. data/lib/chef/solr_query/query_transform.rb +65 -0
  153. data/lib/chef/solr_query/solr_http_request.rb +118 -0
  154. data/lib/chef/version.rb +4 -2
  155. data/lib/chef/version_class.rb +70 -0
  156. data/lib/chef/version_constraint.rb +116 -0
  157. metadata +68 -37
  158. data/lib/chef/cookbook/metadata/version.rb +0 -87
  159. data/lib/chef/knife/bluebox_images_list.rb +0 -54
  160. data/lib/chef/knife/bluebox_server_create.rb +0 -157
  161. data/lib/chef/knife/bluebox_server_delete.rb +0 -63
  162. data/lib/chef/knife/bluebox_server_list.rb +0 -59
  163. data/lib/chef/knife/ec2_instance_data.rb +0 -46
  164. data/lib/chef/knife/ec2_server_create.rb +0 -218
  165. data/lib/chef/knife/ec2_server_delete.rb +0 -87
  166. data/lib/chef/knife/ec2_server_list.rb +0 -89
  167. data/lib/chef/knife/rackspace_server_create.rb +0 -184
  168. data/lib/chef/knife/rackspace_server_delete.rb +0 -57
  169. data/lib/chef/knife/rackspace_server_list.rb +0 -59
  170. data/lib/chef/knife/slicehost_images_list.rb +0 -53
  171. data/lib/chef/knife/slicehost_server_create.rb +0 -103
  172. data/lib/chef/knife/slicehost_server_delete.rb +0 -61
  173. data/lib/chef/knife/slicehost_server_list.rb +0 -64
  174. data/lib/chef/knife/terremark_server_create.rb +0 -152
  175. data/lib/chef/knife/terremark_server_delete.rb +0 -87
  176. data/lib/chef/knife/terremark_server_list.rb +0 -77
  177. data/lib/chef/mixin/find_preferred_file.rb +0 -92
@@ -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
- if file_cache_location && content_stale?
37
- Chef::Log.debug("content of file #{@new_resource.path} requires update")
38
- backup_new_resource
39
- Tempfile.open(::File.basename(@new_resource.name)) do |staging_file|
40
- Chef::Log.debug("staging #{file_cache_location} to #{staging_file.path}")
41
- staging_file.close
42
- stage_file_to_tmpdir(staging_file.path)
43
- FileUtils.mv(staging_file.path, @new_resource.path)
44
- end
45
- @new_resource.updated_by_last_action(true)
46
- else
47
- set_all_access_controls(@new_resource.path)
48
- end
49
- @new_resource.updated_by_last_action?
50
- end
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");
@@ -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
- 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
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
- when /^\d+$/, Integer
104
- @new_resource.group.to_i
105
- else
106
- Etc.getgrnam(@new_resource.group).gid
107
- end
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
@@ -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 load_current_resource
25
- super
26
-
24
+ def required_binaries
27
25
  [ "/usr/sbin/groupadd",
28
26
  "/usr/sbin/groupmod",
29
- "/usr/sbin/groupdel" ].each do |required_binary|
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
@@ -31,7 +31,7 @@ class Chef
31
31
 
32
32
  def modify_group_members
33
33
  case node[:platform]
34
- when "openbsd", "netbsd"
34
+ when "openbsd", "netbsd", "aix"
35
35
  append_flags = "-G"
36
36
  when "solaris"
37
37
  append_flags = "-a -G"