chef 0.9.18 → 0.10.0.beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -38,14 +38,12 @@ Install these via your platform's preferred method; for example apt, yum, ports,
38
38
  * RabbitMQ[http://www.rabbitmq.com/]
39
39
  * GCC and C Standard Libraries, header files, etc. (i.e., build-essential on debian/ubuntu)
40
40
  * Ruby development package
41
- * libxml2 development package
42
41
 
43
42
  === Runtime Rubygem Dependencies
44
43
  ==== Chef Client and Solo
45
44
  * ohai
46
45
  * bunny
47
46
  * erubis
48
- * extlib
49
47
  * highline
50
48
  * json (1.4.4 - 1.4.6)
51
49
  * mixlib-authentication
@@ -61,7 +59,6 @@ Install these via your platform's preferred method; for example apt, yum, ports,
61
59
  All of the above, plus the following:
62
60
  * coderay
63
61
  * haml
64
- * libxml-ruby
65
62
  * merb-assets
66
63
  * merb-core
67
64
  * merb-haml
@@ -51,11 +51,7 @@ case "$1" in
51
51
 
52
52
  stop)
53
53
  stat_busy "Stopping $daemon_name daemon"
54
- <<<<<<< HEAD
55
54
  PID=$(get_pid)
56
- =======
57
- PID=$(gid_pid)
58
- >>>>>>> 26fafb3... CHEF-1938, add boot scripts for archlinux
59
55
  [ ! -z "$PID" ] && kill $PID &> /dev/null
60
56
  if [ $? -gt 0 ]; then
61
57
  stat_fail
@@ -51,11 +51,7 @@ case "$1" in
51
51
 
52
52
  stop)
53
53
  stat_busy "Stopping $daemon_name daemon"
54
- <<<<<<< HEAD
55
54
  PID=$(get_pid)
56
- =======
57
- PID=$(gid_pid)
58
- >>>>>>> 26fafb3... CHEF-1938, add boot scripts for archlinux
59
55
  [ ! -z "$PID" ] && kill $PID &> /dev/null
60
56
  if [ $? -gt 0 ]; then
61
57
  stat_fail
@@ -51,11 +51,7 @@ case "$1" in
51
51
 
52
52
  stop)
53
53
  stat_busy "Stopping $daemon_name daemon"
54
- <<<<<<< HEAD
55
54
  PID=$(get_pid)
56
- =======
57
- PID=$(gid_pid)
58
- >>>>>>> 26fafb3... CHEF-1938, add boot scripts for archlinux
59
55
  [ ! -z "$PID" ] && kill $PID &> /dev/null
60
56
  if [ $? -gt 0 ]; then
61
57
  stat_fail
@@ -51,11 +51,7 @@ case "$1" in
51
51
 
52
52
  stop)
53
53
  stat_busy "Stopping $daemon_name daemon"
54
- <<<<<<< HEAD
55
54
  PID=$(get_pid)
56
- =======
57
- PID=$(gid_pid)
58
- >>>>>>> 26fafb3... CHEF-1938, add boot scripts for archlinux
59
55
  [ ! -z "$PID" ] && kill $PID &> /dev/null
60
56
  if [ $? -gt 0 ]; then
61
57
  stat_fail
@@ -17,8 +17,8 @@
17
17
  #
18
18
 
19
19
  require 'chef/version'
20
-
21
- require 'extlib'
20
+ require 'chef/nil_argument'
21
+ require 'chef/mash'
22
22
  require 'chef/exceptions'
23
23
  require 'chef/log'
24
24
  require 'chef/config'
@@ -37,4 +37,4 @@ require 'chef/handler/json_file'
37
37
  require 'chef/monkey_patches/tempfile'
38
38
  require 'chef/monkey_patches/dir'
39
39
  require 'chef/monkey_patches/string'
40
- require 'chef/monkey_patches/numeric'
40
+ require 'chef/monkey_patches/numeric'
@@ -23,7 +23,7 @@ require 'chef/mixin/from_file'
23
23
  require 'chef/couchdb'
24
24
  require 'chef/certificate'
25
25
  require 'chef/index_queue'
26
- require 'extlib'
26
+ require 'chef/mash'
27
27
  require 'chef/json_compat'
28
28
 
29
29
  class Chef
@@ -86,9 +86,19 @@ class Chef::Application
86
86
 
87
87
  end
88
88
 
89
- # Initialize and configure the logger
89
+ # Initialize and configure the logger. If the configured log location is not
90
+ # STDOUT, but stdout is a TTY and we're not daemonizing, we set up a secondary
91
+ # logger with output to stdout. This way, we magically do the right thing when
92
+ # the user has configured logging to a file but they're running chef in the
93
+ # shell to debug something.
90
94
  def configure_logging
91
95
  Chef::Log.init(Chef::Config[:log_location])
96
+ if ( Chef::Config[:log_location] != STDOUT ) && STDOUT.tty? && (!Chef::Config[:daemonize])
97
+ stdout_logger = Logger.new(STDOUT)
98
+ STDOUT.sync = true
99
+ stdout_logger.formatter = Chef::Log.logger.formatter
100
+ Chef::Log.loggers << stdout_logger
101
+ end
92
102
  Chef::Log.level = Chef::Config[:log_level]
93
103
  end
94
104
 
@@ -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.
@@ -25,14 +25,14 @@ require 'chef/rest'
25
25
 
26
26
 
27
27
  class Chef::Application::Client < Chef::Application
28
-
29
- option :config_file,
28
+
29
+ option :config_file,
30
30
  :short => "-c CONFIG",
31
31
  :long => "--config CONFIG",
32
32
  :default => "/etc/chef/client.rb",
33
33
  :description => "The configuration file to use"
34
34
 
35
- option :log_level,
35
+ option :log_level,
36
36
  :short => "-l LEVEL",
37
37
  :long => "--log_level LEVEL",
38
38
  :description => "Set the log level (debug, info, warn, error, fatal)",
@@ -44,12 +44,6 @@ class Chef::Application::Client < Chef::Application
44
44
  :description => "Set the log file location, defaults to STDOUT - recommended for daemonizing",
45
45
  :proc => nil
46
46
 
47
- option :verbose_logging,
48
- :short => "-V",
49
- :long => "--verbose",
50
- :description => "Ensures logging goes to STDOUT as well as to other configured log location(s).",
51
- :proc => lambda { |p| true }
52
-
53
47
  option :help,
54
48
  :short => "-h",
55
49
  :long => "--help",
@@ -58,7 +52,7 @@ class Chef::Application::Client < Chef::Application
58
52
  :boolean => true,
59
53
  :show_options => true,
60
54
  :exit => 0
61
-
55
+
62
56
  option :user,
63
57
  :short => "-u USER",
64
58
  :long => "--user USER",
@@ -90,7 +84,7 @@ class Chef::Application::Client < Chef::Application
90
84
  :proc => lambda { |s| s.to_i }
91
85
 
92
86
  option :once,
93
- :long => "--short",
87
+ :long => "--once",
94
88
  :description => "Cancel any interval or splay options, run chef once and exit",
95
89
  :boolean => true
96
90
 
@@ -138,20 +132,22 @@ class Chef::Application::Client < Chef::Application
138
132
  :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
139
133
  :exit => 0
140
134
 
135
+ attr_reader :chef_client_json
136
+
141
137
  def initialize
142
138
  super
143
139
 
144
140
  @chef_client = nil
145
141
  @chef_client_json = nil
146
142
  end
147
-
143
+
148
144
  # Reconfigure the chef client
149
145
  # Re-open the JSON attributes and load them into the node
150
- def reconfigure
151
- super
146
+ def reconfigure
147
+ super
152
148
 
153
149
  Chef::Config[:chef_server_url] = config[:chef_server_url] if config.has_key? :chef_server_url
154
-
150
+
155
151
  if Chef::Config[:daemonize]
156
152
  Chef::Config[:interval] ||= 1800
157
153
  end
@@ -191,14 +187,14 @@ class Chef::Application::Client < Chef::Application
191
187
 
192
188
  def configure_logging
193
189
  super
194
- Chef::Log.verbose = Chef::Config[:verbose_logging]
195
- Mixlib::Authentication::Log.logger = Ohai::Log.logger = Chef::Log.logger
190
+ Mixlib::Authentication::Log.use_log_devices( Chef::Log )
191
+ Ohai::Log.use_log_devices( Chef::Log )
196
192
  end
197
-
193
+
198
194
  def setup_application
199
195
  Chef::Daemon.change_privilege
200
196
  end
201
-
197
+
202
198
  # Run the chef client, optionally daemonizing or looping at intervals.
203
199
  def run_application
204
200
  if Chef::Config[:version]
@@ -208,7 +204,7 @@ class Chef::Application::Client < Chef::Application
208
204
  if Chef::Config[:daemonize]
209
205
  Chef::Daemon.daemonize("chef-client")
210
206
  end
211
-
207
+
212
208
  loop do
213
209
  begin
214
210
  if Chef::Config[:splay]
@@ -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,17 +17,8 @@
17
17
 
18
18
  require 'chef/knife'
19
19
  require 'chef/application'
20
- require 'chef/client'
21
- require 'chef/config'
22
- require 'chef/log'
23
- require 'chef/node'
24
- require 'chef/role'
25
- require 'chef/data_bag'
26
- require 'chef/data_bag_item'
27
- require 'chef/rest'
28
- require 'chef/search/query'
29
- require 'tmpdir'
30
- require 'uri'
20
+ require 'mixlib/log'
21
+ require 'ohai'
31
22
 
32
23
  class Chef::Application::Knife < Chef::Application
33
24
 
@@ -35,12 +26,13 @@ class Chef::Application::Knife < Chef::Application
35
26
 
36
27
  banner "Usage: #{$0} sub-command (options)"
37
28
 
38
- option :config_file,
29
+ option :config_file,
39
30
  :short => "-c CONFIG",
40
31
  :long => "--config CONFIG",
41
- :description => "The configuration file to use"
32
+ :description => "The configuration file to use",
33
+ :proc => lambda { |path| File.expand_path(path, Dir.pwd) }
42
34
 
43
- option :log_level,
35
+ option :log_level,
44
36
  :short => "-l LEVEL",
45
37
  :long => "--log_level LEVEL",
46
38
  :description => "Set the log level (debug, info, warn, error, fatal)",
@@ -52,25 +44,30 @@ class Chef::Application::Knife < Chef::Application
52
44
  :description => "Set the log file location, defaults to STDOUT",
53
45
  :proc => nil
54
46
 
47
+ option :environment,
48
+ :short => "-E ENVIRONMENT",
49
+ :long => "--environment ENVIRONMENT",
50
+ :description => "Set the Chef environment"
51
+
55
52
  option :editor,
56
53
  :short => "-e EDITOR",
57
54
  :long => "--editor EDITOR",
58
55
  :description => "Set the editor to use for interactive commands",
59
56
  :default => ENV['EDITOR']
60
-
57
+
61
58
  option :no_editor,
62
59
  :short => "-n",
63
60
  :long => "--no-editor",
64
61
  :description => "Do not open EDITOR, just accept the data as is",
65
62
  :boolean => true
66
-
63
+
67
64
  option :help,
68
65
  :short => "-h",
69
66
  :long => "--help",
70
67
  :description => "Show this message",
71
68
  :on => :tail,
72
69
  :boolean => true
73
-
70
+
74
71
  option :node_name,
75
72
  :short => "-u USER",
76
73
  :long => "--user USER",
@@ -79,7 +76,8 @@ class Chef::Application::Knife < Chef::Application
79
76
  option :client_key,
80
77
  :short => "-k KEY",
81
78
  :long => "--key KEY",
82
- :description => "API Client Key"
79
+ :description => "API Client Key",
80
+ :proc => lambda { |path| File.expand_path(path, Dir.pwd) }
83
81
 
84
82
  option :chef_server_url,
85
83
  :short => "-s URL",
@@ -96,6 +94,7 @@ class Chef::Application::Knife < Chef::Application
96
94
  :description => "Accept default values for all questions"
97
95
 
98
96
  option :print_after,
97
+ :short => "-p",
99
98
  :long => "--print-after",
100
99
  :description => "Show the data after a destructive operation"
101
100
 
@@ -113,16 +112,16 @@ class Chef::Application::Knife < Chef::Application
113
112
  :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
114
113
  :exit => 0
115
114
 
116
- # Run knife
115
+ # Run knife
117
116
  def run
118
117
  Mixlib::Log::Formatter.show_time = false
119
118
  validate_and_parse_options
120
119
  Chef::Knife.run(ARGV, options)
121
120
  exit 0
122
121
  end
123
-
122
+
124
123
  private
125
-
124
+
126
125
  def validate_and_parse_options
127
126
  # Checking ARGV validity *before* parse_options because parse_options
128
127
  # mangles ARGV in some situations
@@ -131,16 +130,16 @@ class Chef::Application::Knife < Chef::Application
131
130
  elsif no_subcommand_given?
132
131
  if (want_help? || want_version?)
133
132
  print_help_and_exit
134
- else
133
+ else
135
134
  print_help_and_exit(2, NO_COMMAND_GIVEN)
136
135
  end
137
136
  end
138
137
  end
139
-
138
+
140
139
  def no_subcommand_given?
141
140
  ARGV[0] =~ /^-/
142
141
  end
143
-
142
+
144
143
  def no_command_given?
145
144
  ARGV.empty?
146
145
  end
@@ -152,10 +151,10 @@ class Chef::Application::Knife < Chef::Application
152
151
  def want_version?
153
152
  ARGV[0] =~ /^(--version|-v)$/
154
153
  end
155
-
154
+
156
155
  def print_help_and_exit(exitcode=1, fatal_message=nil)
157
156
  Chef::Log.error(fatal_message) if fatal_message
158
-
157
+
159
158
  begin
160
159
  self.parse_options
161
160
  rescue OptionParser::InvalidOption => e
@@ -166,5 +165,5 @@ class Chef::Application::Knife < Chef::Application
166
165
  Chef::Knife.list_commands
167
166
  exit exitcode
168
167
  end
169
-
168
+
170
169
  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.
@@ -26,14 +26,14 @@ require 'open-uri'
26
26
  require 'fileutils'
27
27
 
28
28
  class Chef::Application::Solo < Chef::Application
29
-
30
- option :config_file,
29
+
30
+ option :config_file,
31
31
  :short => "-c CONFIG",
32
32
  :long => "--config CONFIG",
33
33
  :default => "/etc/chef/solo.rb",
34
34
  :description => "The configuration file to use"
35
35
 
36
- option :log_level,
36
+ option :log_level,
37
37
  :short => "-l LEVEL",
38
38
  :long => "--log_level LEVEL",
39
39
  :description => "Set the log level (debug, info, warn, error, fatal)",
@@ -101,7 +101,7 @@ class Chef::Application::Solo < Chef::Application
101
101
  :long => "--recipe-url RECIPE_URL",
102
102
  :description => "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache.",
103
103
  :proc => nil
104
-
104
+
105
105
  option :version,
106
106
  :short => "-v",
107
107
  :long => "--version",
@@ -110,21 +110,23 @@ class Chef::Application::Solo < Chef::Application
110
110
  :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
111
111
  :exit => 0
112
112
 
113
+ attr_reader :chef_solo_json
114
+
113
115
  def initialize
114
116
  super
115
117
  @chef_solo = nil
116
118
  @chef_solo_json = nil
117
119
  end
118
-
120
+
119
121
  def reconfigure
120
122
  super
121
-
123
+
122
124
  Chef::Config[:solo] = true
123
125
 
124
126
  if Chef::Config[:daemonize]
125
127
  Chef::Config[:interval] ||= 1800
126
128
  end
127
-
129
+
128
130
  if Chef::Config[:json_attribs]
129
131
  begin
130
132
  json_io = case Chef::Config[:json_attribs]
@@ -151,7 +153,7 @@ class Chef::Application::Solo < Chef::Application
151
153
  Chef::Application.fatal!("Could not parse the provided JSON file (#{Chef::Config[:json_attribs]})!: " + error.message, 2)
152
154
  end
153
155
  end
154
-
156
+
155
157
  if Chef::Config[:recipe_url]
156
158
  cookbooks_path = Array(Chef::Config[:cookbook_path]).detect{|e| e =~ /\/cookbooks\/*$/ }
157
159
  recipes_path = File.expand_path(File.join(cookbooks_path, '..'))
@@ -168,11 +170,11 @@ class Chef::Application::Solo < Chef::Application
168
170
  Chef::Mixin::Command.run_command(:command => "tar zxvfC #{path} #{recipes_path}")
169
171
  end
170
172
  end
171
-
173
+
172
174
  def setup_application
173
175
  Chef::Daemon.change_privilege
174
176
  end
175
-
177
+
176
178
  def run_application
177
179
  if Chef::Config[:daemonize]
178
180
  Chef::Daemon.daemonize("chef-client")