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
@@ -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.
@@ -17,13 +17,16 @@
17
17
  #
18
18
 
19
19
  require 'chef/knife'
20
- require 'chef/api_client'
21
- require 'chef/json_compat'
22
20
 
23
21
  class Chef
24
22
  class Knife
25
23
  class ClientList < Knife
26
24
 
25
+ deps do
26
+ require 'chef/api_client'
27
+ require 'chef/json_compat'
28
+ end
29
+
27
30
  banner "knife client list (options)"
28
31
 
29
32
  option :with_uri,
@@ -31,7 +34,7 @@ class Chef
31
34
  :long => "--with-uri",
32
35
  :description => "Show corresponding URIs"
33
36
 
34
- def run
37
+ def run
35
38
  output(format_list_for_display(Chef::ApiClient.list))
36
39
  end
37
40
  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.
@@ -17,13 +17,16 @@
17
17
  #
18
18
 
19
19
  require 'chef/knife'
20
- require 'chef/api_client'
21
- require 'chef/json_compat'
22
20
 
23
21
  class Chef
24
22
  class Knife
25
23
  class ClientReregister < Knife
26
24
 
25
+ deps do
26
+ require 'chef/api_client'
27
+ require 'chef/json_compat'
28
+ end
29
+
27
30
  banner "knife client reregister CLIENT (options)"
28
31
 
29
32
  option :file,
@@ -36,10 +39,10 @@ class Chef
36
39
 
37
40
  if @client_name.nil?
38
41
  show_usage
39
- Chef::Log.fatal("You must specify a client name")
42
+ ui.fatal("You must specify a client name")
40
43
  exit 1
41
44
  end
42
-
45
+
43
46
  client = Chef::ApiClient.load(@client_name)
44
47
  key = client.save(true)
45
48
  if config[:file]
@@ -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.
@@ -17,13 +17,16 @@
17
17
  #
18
18
 
19
19
  require 'chef/knife'
20
- require 'chef/api_client'
21
- require 'chef/json_compat'
22
20
 
23
21
  class Chef
24
22
  class Knife
25
23
  class ClientShow < Knife
26
24
 
25
+ deps do
26
+ require 'chef/api_client'
27
+ require 'chef/json_compat'
28
+ end
29
+
27
30
  banner "knife client show CLIENT (options)"
28
31
 
29
32
  option :attribute,
@@ -36,10 +39,10 @@ class Chef
36
39
 
37
40
  if @client_name.nil?
38
41
  show_usage
39
- Chef::Log.fatal("You must specify a client name")
42
+ ui.fatal("You must specify a client name")
40
43
  exit 1
41
44
  end
42
-
45
+
43
46
  client = Chef::ApiClient.load(@client_name)
44
47
  output(format_for_display(client))
45
48
  end
@@ -47,10 +47,6 @@ class Chef
47
47
  def run
48
48
  ask_user_for_config_path
49
49
 
50
- Mixlib::Log::Formatter.show_time = false
51
- Chef::Log.init(STDOUT)
52
- Chef::Log.level(:info)
53
-
54
50
  FileUtils.mkdir_p(chef_config_path)
55
51
 
56
52
  ask_user_for_config
@@ -73,7 +69,7 @@ EOH
73
69
  end
74
70
 
75
71
  if config[:initial]
76
- Chef::Log.warn("Creating initial API user...")
72
+ ui.msg("Creating initial API user...")
77
73
  Chef::Config[:chef_server_url] = chef_server
78
74
  Chef::Config[:node_name] = admin_client_name
79
75
  Chef::Config[:client_key] = admin_client_key
@@ -85,22 +81,22 @@ EOH
85
81
  client_create.config[:no_editor] = true
86
82
  client_create.run
87
83
  else
88
- Chef::Log.warn("*****")
89
- Chef::Log.warn("")
90
- Chef::Log.warn("You must place your client key in:")
91
- Chef::Log.warn(" #{new_client_key}")
92
- Chef::Log.warn("Before running commands with Knife!")
93
- Chef::Log.warn("")
94
- Chef::Log.warn("*****")
95
- Chef::Log.warn("")
96
- Chef::Log.warn("You must place your validation key in:")
97
- Chef::Log.warn(" #{validation_key}")
98
- Chef::Log.warn("Before generating instance data with Knife!")
99
- Chef::Log.warn("")
100
- Chef::Log.warn("*****")
84
+ ui.msg("*****")
85
+ ui.msg("")
86
+ ui.msg("You must place your client key in:")
87
+ ui.msg(" #{new_client_key}")
88
+ ui.msg("Before running commands with Knife!")
89
+ ui.msg("")
90
+ ui.msg("*****")
91
+ ui.msg("")
92
+ ui.msg("You must place your validation key in:")
93
+ ui.msg(" #{validation_key}")
94
+ ui.msg("Before generating instance data with Knife!")
95
+ ui.msg("")
96
+ ui.msg("*****")
101
97
  end
102
98
 
103
- Chef::Log.warn("Configuration file written to #{config[:config_file]}")
99
+ ui.msg("Configuration file written to #{config[:config_file]}")
104
100
  end
105
101
 
106
102
  def ask_user_for_config_path
@@ -25,21 +25,21 @@ class Chef
25
25
 
26
26
  def run
27
27
  unless @config_dir = @name_args[0]
28
- Chef::Log.fatal "You must provide the directory to put the files in"
28
+ ui.fatal "You must provide the directory to put the files in"
29
29
  show_usage
30
30
  exit(1)
31
31
  end
32
32
 
33
- Chef::Log.info("Creating client configuration")
33
+ ui.info("Creating client configuration")
34
34
  FileUtils.mkdir_p(@config_dir)
35
- Chef::Log.info("Writing client.rb")
35
+ ui.info("Writing client.rb")
36
36
  File.open(File.join(@config_dir, "client.rb"), "w") do |file|
37
37
  file.puts('log_level :info')
38
38
  file.puts('log_location STDOUT')
39
39
  file.puts("chef_server_url '#{Chef::Config[:chef_server_url]}'")
40
40
  file.puts("validation_client_name '#{Chef::Config[:validation_client_name]}'")
41
41
  end
42
- Chef::Log.info("Writing validation.pem")
42
+ ui.info("Writing validation.pem")
43
43
  File.open(File.join(@config_dir, 'validation.pem'), "w") do |validation|
44
44
  validation.puts(IO.read(Chef::Config[:validation_key]))
45
45
  end
@@ -7,9 +7,9 @@
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
8
8
  # you may not use this file except in compliance with the License.
9
9
  # You may obtain a copy of the License at
10
- #
10
+ #
11
11
  # http://www.apache.org/licenses/LICENSE-2.0
12
- #
12
+ #
13
13
  # Unless required by applicable law or agreed to in writing, software
14
14
  # distributed under the License is distributed on an "AS IS" BASIS,
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,19 +18,22 @@
18
18
  #
19
19
 
20
20
  require 'chef/knife'
21
- require 'chef/knife/cookbook_delete'
22
21
 
23
22
  class Chef
24
23
  class Knife
25
24
  class CookbookBulkDelete < Knife
26
25
 
26
+ deps do
27
+ require 'chef/knife/cookbook_delete'
28
+ end
29
+
27
30
  option :purge, :short => '-p', :long => '--purge', :boolean => true, :description => 'Permanently remove files from backing data store'
28
-
31
+
29
32
  banner "knife cookbook bulk delete REGEX (options)"
30
33
 
31
34
  def run
32
35
  unless regex_str = @name_args.first
33
- Chef::Log.fatal("You must supply a regular expression to match the results against")
36
+ ui.fatal("You must supply a regular expression to match the results against")
34
37
  exit 42
35
38
  end
36
39
 
@@ -42,14 +45,14 @@ class Chef
42
45
  output(format_list_for_display(cookbooks_to_delete))
43
46
 
44
47
  confirm("Do you really want to delete these cookbooks? All versions will be deleted. (Y/N) ", false)
45
-
48
+
46
49
  confirm("Files that are common to multiple cookbooks are shared, so purging the files may disable other cookbooks. Are you sure you want to purge files instead of just deleting the cookbooks") if config[:purge]
47
-
50
+
48
51
  cookbooks_names.each do |cookbook_name|
49
52
  versions = rest.get_rest("cookbooks/#{cookbook_name}").values.flatten
50
53
  versions.each do |version|
51
54
  object = rest.delete_rest("cookbooks/#{cookbook_name}/#{version}#{config[:purge] ? "?purge=true" : ""}")
52
- Chef::Log.info("Deleted cookbook #{cookbook_name.ljust(25)} [#{version}]")
55
+ ui.info("Deleted cookbook #{cookbook_name.ljust(25)} [#{version}]")
53
56
  end
54
57
  end
55
58
  end
@@ -17,14 +17,16 @@
17
17
  #
18
18
 
19
19
  require 'chef/knife'
20
- require 'chef/json_compat'
21
- require 'uri'
22
- require 'chef/mixin/shell_out'
23
20
 
24
21
  class Chef
25
22
  class Knife
26
23
  class CookbookCreate < Knife
27
- include Chef::Mixin::ShellOut
24
+
25
+ deps do
26
+ require 'chef/json_compat'
27
+ require 'uri'
28
+ require 'fileutils'
29
+ end
28
30
 
29
31
  banner "knife cookbook create COOKBOOK (options)"
30
32
 
@@ -42,7 +44,7 @@ class Chef
42
44
  option :cookbook_license,
43
45
  :short => "-I LICENSE",
44
46
  :long => "--license LICENSE",
45
- :description => "License for cookbook, apachev2 or none"
47
+ :description => "License for cookbook, apachev2, gplv2, gplv3, mit or none"
46
48
 
47
49
  option :cookbook_copyright,
48
50
  :short => "-C COPYRIGHT",
@@ -50,7 +52,7 @@ class Chef
50
52
  :description => "Name of Copyright holder"
51
53
 
52
54
  option :cookbook_email,
53
- :short => "-E EMAIL",
55
+ :short => "-m EMAIL",
54
56
  :long => "--email EMAIL",
55
57
  :description => "Email address of cookbook maintainer"
56
58
 
@@ -58,7 +60,7 @@ class Chef
58
60
  self.config = Chef::Config.merge!(config)
59
61
  if @name_args.length < 1
60
62
  show_usage
61
- Chef::Log.fatal("You must specify a cookbook name")
63
+ ui.fatal("You must specify a cookbook name")
62
64
  exit 1
63
65
  end
64
66
 
@@ -74,21 +76,21 @@ class Chef
74
76
  create_cookbook(cookbook_path,cookbook_name, copyright, license)
75
77
  create_readme(cookbook_path,cookbook_name)
76
78
  create_metadata(cookbook_path,cookbook_name, copyright, email, license)
77
- end
79
+ end
78
80
 
79
- def create_cookbook(dir, cookbook_name, copyright, license)
80
- msg("** Creating cookbook #{cookbook_name}")
81
- shell_out "mkdir -p #{File.join(dir, cookbook_name, "attributes")}"
82
- shell_out "mkdir -p #{File.join(dir, cookbook_name, "recipes")}"
83
- shell_out "mkdir -p #{File.join(dir, cookbook_name, "definitions")}"
84
- shell_out "mkdir -p #{File.join(dir, cookbook_name, "libraries")}"
85
- shell_out "mkdir -p #{File.join(dir, cookbook_name, "resources")}"
86
- shell_out "mkdir -p #{File.join(dir, cookbook_name, "providers")}"
87
- shell_out "mkdir -p #{File.join(dir, cookbook_name, "files", "default")}"
88
- shell_out "mkdir -p #{File.join(dir, cookbook_name, "templates", "default")}"
89
- unless File.exists?(File.join(dir, cookbook_name, "recipes", "default.rb"))
90
- open(File.join(dir, cookbook_name, "recipes", "default.rb"), "w") do |file|
91
- file.puts <<-EOH
81
+ def create_cookbook(dir, cookbook_name, copyright, license)
82
+ msg("** Creating cookbook #{cookbook_name}")
83
+ FileUtils.mkdir_p "#{File.join(dir, cookbook_name, "attributes")}"
84
+ FileUtils.mkdir_p "#{File.join(dir, cookbook_name, "recipes")}"
85
+ FileUtils.mkdir_p "#{File.join(dir, cookbook_name, "definitions")}"
86
+ FileUtils.mkdir_p "#{File.join(dir, cookbook_name, "libraries")}"
87
+ FileUtils.mkdir_p "#{File.join(dir, cookbook_name, "resources")}"
88
+ FileUtils.mkdir_p "#{File.join(dir, cookbook_name, "providers")}"
89
+ FileUtils.mkdir_p "#{File.join(dir, cookbook_name, "files", "default")}"
90
+ FileUtils.mkdir_p "#{File.join(dir, cookbook_name, "templates", "default")}"
91
+ unless File.exists?(File.join(dir, cookbook_name, "recipes", "default.rb"))
92
+ open(File.join(dir, cookbook_name, "recipes", "default.rb"), "w") do |file|
93
+ file.puts <<-EOH
92
94
  #
93
95
  # Cookbook Name:: #{cookbook_name}
94
96
  # Recipe:: default
@@ -96,9 +98,9 @@ class Chef
96
98
  # Copyright #{Time.now.year}, #{copyright}
97
99
  #
98
100
  EOH
99
- case license
100
- when "apachev2"
101
- file.puts <<-EOH
101
+ case license
102
+ when "apachev2"
103
+ file.puts <<-EOH
102
104
  # Licensed under the Apache License, Version 2.0 (the "License");
103
105
  # you may not use this file except in compliance with the License.
104
106
  # You may obtain a copy of the License at
@@ -112,23 +114,78 @@ EOH
112
114
  # limitations under the License.
113
115
  #
114
116
  EOH
115
- when "none"
116
- file.puts <<-EOH
117
+ when "gplv2"
118
+ file.puts <<-EOH
119
+ # This program is free software; you can redistribute it and/or modify
120
+ # it under the terms of the GNU General Public License as published by
121
+ # the Free Software Foundation; either version 2 of the License, or
122
+ # (at your option) any later version.
123
+ #
124
+ # This program is distributed in the hope that it will be useful,
125
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
126
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
127
+ # GNU General Public License for more details.
128
+ #
129
+ # You should have received a copy of the GNU General Public License along
130
+ # with this program; if not, write to the Free Software Foundation, Inc.,
131
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
132
+ #
133
+ EOH
134
+ when "gplv3"
135
+ file.puts <<-EOH
136
+ # This program is free software: you can redistribute it and/or modify
137
+ # it under the terms of the GNU General Public License as published by
138
+ # the Free Software Foundation, either version 3 of the License, or
139
+ # (at your option) any later version.
140
+ #
141
+ # This program is distributed in the hope that it will be useful,
142
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
143
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144
+ # GNU General Public License for more details.
145
+ #
146
+ # You should have received a copy of the GNU General Public License
147
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
148
+ #
149
+ EOH
150
+ when "mit"
151
+ file.puts <<-EOH
152
+ # Permission is hereby granted, free of charge, to any person obtaining
153
+ # a copy of this software and associated documentation files (the
154
+ # "Software"), to deal in the Software without restriction, including
155
+ # without limitation the rights to use, copy, modify, merge, publish,
156
+ # distribute, sublicense, and/or sell copies of the Software, and to
157
+ # permit persons to whom the Software is furnished to do so, subject to
158
+ # the following conditions:
159
+ #
160
+ # The above copyright notice and this permission notice shall be
161
+ # included in all copies or substantial portions of the Software.
162
+ #
163
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
164
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
165
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
166
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
167
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
168
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
169
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
170
+ #
171
+ EOH
172
+ when "none"
173
+ file.puts <<-EOH
117
174
  # All rights reserved - Do Not Redistribute
118
175
  #
119
176
  EOH
177
+ end
120
178
  end
121
179
  end
122
180
  end
123
- end
124
181
 
125
- def create_readme(dir, cookbook_name)
126
- msg("** Creating README for cookbook: #{cookbook_name}")
127
- unless File.exists?(File.join(dir, cookbook_name, "README.#{config[:readme_format]}"))
128
- open(File.join(dir, cookbook_name, "README.#{config[:readme_format]}"), "w") do |file|
129
- case config[:readme_format]
130
- when "rdoc"
131
- file.puts <<-EOH
182
+ def create_readme(dir, cookbook_name)
183
+ msg("** Creating README for cookbook: #{cookbook_name}")
184
+ unless File.exists?(File.join(dir, cookbook_name, "README.#{config[:readme_format]}"))
185
+ open(File.join(dir, cookbook_name, "README.#{config[:readme_format]}"), "w") do |file|
186
+ case config[:readme_format]
187
+ when "rdoc"
188
+ file.puts <<-EOH
132
189
  = DESCRIPTION:
133
190
 
134
191
  = REQUIREMENTS:
@@ -138,8 +195,8 @@ EOH
138
195
  = USAGE:
139
196
 
140
197
  EOH
141
- when "md","mkd","txt"
142
- file.puts <<-EOH
198
+ when "md","mkd","txt"
199
+ file.puts <<-EOH
143
200
  Description
144
201
  ===========
145
202
 
@@ -153,8 +210,8 @@ Usage
153
210
  =====
154
211
 
155
212
  EOH
156
- else
157
- file.puts <<-EOH
213
+ else
214
+ file.puts <<-EOH
158
215
  Description
159
216
 
160
217
  Requirements
@@ -164,27 +221,33 @@ Attributes
164
221
  Usage
165
222
 
166
223
  EOH
224
+ end
167
225
  end
168
226
  end
169
227
  end
170
- end
171
228
 
172
- def create_metadata(dir, cookbook_name, copyright, email, license)
173
- msg("** Creating metadata for cookbook: #{cookbook_name}")
229
+ def create_metadata(dir, cookbook_name, copyright, email, license)
230
+ msg("** Creating metadata for cookbook: #{cookbook_name}")
174
231
 
175
- license_name = case license
176
- when "apachev2"
177
- "Apache 2.0"
178
- when "none"
179
- "All rights reserved"
180
- end
232
+ license_name = case license
233
+ when "apachev2"
234
+ "Apache 2.0"
235
+ when "gplv2"
236
+ "GNU Public License 2.0"
237
+ when "gplv3"
238
+ "GNU Public License 3.0"
239
+ when "mit"
240
+ "MIT"
241
+ when "none"
242
+ "All rights reserved"
243
+ end
181
244
 
182
- unless File.exists?(File.join(dir, cookbook_name, "metadata.rb"))
183
- open(File.join(dir, cookbook_name, "metadata.rb"), "w") do |file|
184
- if File.exists?(File.join(dir, cookbook_name, "README.#{config[:readme_format]}"))
185
- long_description = "long_description IO.read(File.join(File.dirname(__FILE__), 'README.#{config[:readme_format]}'))"
186
- end
187
- file.puts <<-EOH
245
+ unless File.exists?(File.join(dir, cookbook_name, "metadata.rb"))
246
+ open(File.join(dir, cookbook_name, "metadata.rb"), "w") do |file|
247
+ if File.exists?(File.join(dir, cookbook_name, "README.#{config[:readme_format]}"))
248
+ long_description = "long_description IO.read(File.join(File.dirname(__FILE__), 'README.#{config[:readme_format]}'))"
249
+ end
250
+ file.puts <<-EOH
188
251
  maintainer "#{copyright}"
189
252
  maintainer_email "#{email}"
190
253
  license "#{license_name}"
@@ -192,11 +255,12 @@ description "Installs/Configures #{cookbook_name}"
192
255
  #{long_description}
193
256
  version "0.0.1"
194
257
  EOH
258
+ end
195
259
  end
196
260
  end
197
- end
198
261
 
199
- private
262
+ private
263
+
200
264
  def default_cookbook_path_empty?
201
265
  Chef::Config[:cookbook_path].nil? || Chef::Config[:cookbook_path].empty?
202
266
  end
@@ -204,6 +268,7 @@ EOH
204
268
  def parameter_empty?(parameter)
205
269
  parameter.nil? || parameter.empty?
206
270
  end
271
+
207
272
  end
208
273
  end
209
274
  end