chef 11.12.8-x86-mingw32 → 11.14.0.alpha.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -2
  3. data/distro/common/html/_sources/index.txt +6 -0
  4. data/distro/common/html/_sources/knife_ssl_check.txt +41 -0
  5. data/distro/common/html/_sources/knife_ssl_fetch.txt +41 -0
  6. data/distro/common/html/_static/basic.css +2 -5
  7. data/distro/common/html/_static/doctools.js +5 -14
  8. data/distro/common/html/_static/jquery.js +2 -154
  9. data/distro/common/html/_static/pygments.css +2 -2
  10. data/distro/common/html/_static/searchtools.js +212 -150
  11. data/distro/common/html/_static/underscore.js +29 -21
  12. data/distro/common/html/_static/websupport.js +1 -1
  13. data/distro/common/html/ctl_chef_client.html +15 -18
  14. data/distro/common/html/ctl_chef_server.html +7 -7
  15. data/distro/common/html/ctl_chef_shell.html +6 -6
  16. data/distro/common/html/ctl_chef_solo.html +7 -8
  17. data/distro/common/html/index.html +34 -24
  18. data/distro/common/html/knife.html +23 -24
  19. data/distro/common/html/knife_bootstrap.html +13 -9
  20. data/distro/common/html/knife_client.html +10 -11
  21. data/distro/common/html/knife_common_options.html +6 -7
  22. data/distro/common/html/knife_configure.html +3 -4
  23. data/distro/common/html/knife_cookbook.html +18 -11
  24. data/distro/common/html/knife_cookbook_site.html +14 -14
  25. data/distro/common/html/knife_data_bag.html +24 -23
  26. data/distro/common/html/knife_delete.html +4 -5
  27. data/distro/common/html/knife_deps.html +4 -5
  28. data/distro/common/html/knife_diff.html +6 -7
  29. data/distro/common/html/knife_download.html +12 -13
  30. data/distro/common/html/knife_edit.html +4 -5
  31. data/distro/common/html/knife_environment.html +8 -9
  32. data/distro/common/html/knife_exec.html +9 -10
  33. data/distro/common/html/knife_index_rebuild.html +4 -5
  34. data/distro/common/html/knife_list.html +8 -9
  35. data/distro/common/html/knife_node.html +34 -33
  36. data/distro/common/html/knife_raw.html +2 -3
  37. data/distro/common/html/knife_recipe_list.html +3 -4
  38. data/distro/common/html/knife_role.html +30 -29
  39. data/distro/common/html/knife_search.html +7 -7
  40. data/distro/common/html/knife_show.html +4 -5
  41. data/distro/common/html/knife_ssh.html +2 -3
  42. data/distro/common/html/knife_ssl_check.html +148 -0
  43. data/distro/common/html/knife_ssl_fetch.html +152 -0
  44. data/distro/common/html/knife_status.html +4 -5
  45. data/distro/common/html/knife_tag.html +2 -3
  46. data/distro/common/html/knife_upload.html +5 -6
  47. data/distro/common/html/knife_user.html +9 -10
  48. data/distro/common/html/knife_using.html +12 -12
  49. data/distro/common/html/knife_xargs.html +11 -12
  50. data/distro/common/html/search.html +1 -2
  51. data/distro/common/html/searchindex.js +1 -1
  52. data/distro/common/man/man1/chef-shell.1 +19 -11
  53. data/distro/common/man/man1/knife-bootstrap.1 +35 -19
  54. data/distro/common/man/man1/knife-client.1 +111 -28
  55. data/distro/common/man/man1/knife-configure.1 +30 -14
  56. data/distro/common/man/man1/knife-cookbook-site.1 +105 -22
  57. data/distro/common/man/man1/knife-cookbook.1 +164 -23
  58. data/distro/common/man/man1/knife-data-bag.1 +157 -33
  59. data/distro/common/man/man1/knife-delete.1 +21 -17
  60. data/distro/common/man/man1/knife-deps.1 +60 -16
  61. data/distro/common/man/man1/knife-diff.1 +37 -17
  62. data/distro/common/man/man1/knife-download.1 +68 -24
  63. data/distro/common/man/man1/knife-edit.1 +19 -15
  64. data/distro/common/man/man1/knife-environment.1 +105 -17
  65. data/distro/common/man/man1/knife-exec.1 +78 -18
  66. data/distro/common/man/man1/knife-index-rebuild.1 +16 -8
  67. data/distro/common/man/man1/knife-list.1 +39 -23
  68. data/distro/common/man/man1/knife-node.1 +170 -22
  69. data/distro/common/man/man1/knife-raw.1 +33 -13
  70. data/distro/common/man/man1/knife-recipe-list.1 +17 -5
  71. data/distro/common/man/man1/knife-role.1 +86 -18
  72. data/distro/common/man/man1/knife-search.1 +80 -16
  73. data/distro/common/man/man1/knife-show.1 +30 -14
  74. data/distro/common/man/man1/knife-ssh.1 +54 -14
  75. data/distro/common/man/man1/knife-ssl-check.1 +207 -0
  76. data/distro/common/man/man1/knife-ssl-fetch.1 +207 -0
  77. data/distro/common/man/man1/knife-status.1 +48 -12
  78. data/distro/common/man/man1/knife-tag.1 +30 -10
  79. data/distro/common/man/man1/knife-upload.1 +72 -20
  80. data/distro/common/man/man1/knife-user.1 +79 -23
  81. data/distro/common/man/man1/knife-xargs.1 +61 -53
  82. data/distro/common/man/man8/chef-client.8 +87 -29
  83. data/distro/common/man/man8/chef-solo.8 +36 -15
  84. data/lib/chef/application.rb +19 -14
  85. data/lib/chef/application/client.rb +5 -0
  86. data/lib/chef/application/solo.rb +5 -0
  87. data/lib/chef/application/windows_service_manager.rb +3 -0
  88. data/lib/chef/chef_fs/chef_fs_data_store.rb +72 -24
  89. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +20 -4
  90. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +20 -1
  91. data/lib/chef/chef_fs/file_system/file_system_entry.rb +10 -2
  92. data/lib/chef/client.rb +2 -3
  93. data/lib/chef/config.rb +34 -8
  94. data/lib/chef/cookbook/cookbook_version_loader.rb +45 -4
  95. data/lib/chef/cookbook_version.rb +38 -30
  96. data/lib/chef/dsl/recipe.rb +4 -1
  97. data/lib/chef/event_dispatch/base.rb +14 -0
  98. data/lib/chef/event_dispatch/events_output_stream.rb +29 -0
  99. data/lib/chef/exceptions.rb +8 -0
  100. data/lib/chef/formatters/base.rb +16 -45
  101. data/lib/chef/formatters/doc.rb +51 -26
  102. data/lib/chef/formatters/indentable_output_stream.rb +165 -0
  103. data/lib/chef/knife/node_environment_set.rb +54 -0
  104. data/lib/chef/knife/user_create.rb +1 -1
  105. data/lib/chef/monkey_patches/pathname.rb +32 -0
  106. data/lib/chef/node.rb +1 -1
  107. data/lib/chef/platform/provider_mapping.rb +345 -338
  108. data/lib/chef/policy_builder/expand_node_object.rb +1 -1
  109. data/lib/chef/policy_builder/policyfile.rb +1 -1
  110. data/lib/chef/provider.rb +1 -0
  111. data/lib/chef/provider/git.rb +1 -1
  112. data/lib/chef/provider/link.rb +2 -2
  113. data/lib/chef/provider/remote_file/content.rb +1 -1
  114. data/lib/chef/provider/remote_file/local_file.rb +8 -2
  115. data/lib/chef/provider/service/arch.rb +0 -1
  116. data/lib/chef/provider/service/debian.rb +0 -2
  117. data/lib/chef/provider/service/freebsd.rb +2 -1
  118. data/lib/chef/provider/service/gentoo.rb +1 -1
  119. data/lib/chef/provider/service/init.rb +0 -1
  120. data/lib/chef/provider/service/insserv.rb +0 -2
  121. data/lib/chef/provider/service/invokercd.rb +0 -2
  122. data/lib/chef/provider/service/macosx.rb +2 -1
  123. data/lib/chef/provider/service/redhat.rb +0 -1
  124. data/lib/chef/provider/service/simple.rb +1 -0
  125. data/lib/chef/provider/service/solaris.rb +1 -0
  126. data/lib/chef/provider/service/systemd.rb +1 -1
  127. data/lib/chef/provider/service/upstart.rb +1 -1
  128. data/lib/chef/provider/user.rb +9 -9
  129. data/lib/chef/provider/user/solaris.rb +2 -0
  130. data/lib/chef/resource.rb +1 -0
  131. data/lib/chef/resource/remote_file.rb +32 -6
  132. data/lib/chef/run_context.rb +22 -0
  133. data/lib/chef/run_lock.rb +43 -4
  134. data/lib/chef/version.rb +2 -2
  135. data/spec/functional/http/simple_spec.rb +84 -0
  136. data/spec/functional/resource/remote_file_spec.rb +107 -43
  137. data/spec/functional/rest_spec.rb +94 -0
  138. data/spec/functional/run_lock_spec.rb +1 -1
  139. data/spec/functional/win32/service_manager_spec.rb +6 -0
  140. data/spec/integration/knife/chef_fs_data_store_spec.rb +2 -0
  141. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +76 -0
  142. data/spec/spec_helper.rb +2 -0
  143. data/spec/support/mock/platform.rb +7 -0
  144. data/spec/support/pedant/pedant_config.rb +121 -0
  145. data/spec/support/pedant/run_pedant.rb +63 -0
  146. data/spec/support/pedant/stickywicket.pem +27 -0
  147. data/spec/support/shared/functional/http.rb +242 -0
  148. data/spec/support/shared/unit/api_error_inspector.rb +2 -2
  149. data/spec/unit/api_client_spec.rb +2 -2
  150. data/spec/unit/application/client_spec.rb +6 -1
  151. data/spec/unit/application/knife_spec.rb +4 -0
  152. data/spec/unit/application/solo_spec.rb +2 -0
  153. data/spec/unit/application_spec.rb +7 -0
  154. data/spec/unit/client_spec.rb +16 -0
  155. data/spec/unit/config_spec.rb +3 -20
  156. data/spec/unit/cookbook_version_spec.rb +224 -122
  157. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +2 -2
  158. data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +2 -2
  159. data/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb +2 -2
  160. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +2 -2
  161. data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +2 -2
  162. data/spec/unit/handler_spec.rb +0 -1
  163. data/spec/unit/knife/client_bulk_delete_spec.rb +3 -0
  164. data/spec/unit/knife/cookbook_bulk_delete_spec.rb +2 -0
  165. data/spec/unit/knife/cookbook_metadata_spec.rb +2 -2
  166. data/spec/unit/knife/cookbook_site_install_spec.rb +3 -1
  167. data/spec/unit/knife/cookbook_upload_spec.rb +10 -10
  168. data/spec/unit/knife/node_environment_set_spec.rb +80 -0
  169. data/spec/unit/knife/user_create_spec.rb +6 -4
  170. data/spec/unit/knife/user_edit_spec.rb +5 -0
  171. data/spec/unit/knife_spec.rb +3 -0
  172. data/spec/unit/mixin/securable_spec.rb +18 -20
  173. data/spec/unit/node/attribute_spec.rb +15 -2
  174. data/spec/unit/node/immutable_collections_spec.rb +4 -4
  175. data/spec/unit/provider/cron_spec.rb +14 -14
  176. data/spec/unit/provider/git_spec.rb +4 -4
  177. data/spec/unit/provider/group_spec.rb +1 -1
  178. data/spec/unit/provider/ohai_spec.rb +2 -2
  179. data/spec/unit/provider/remote_file/content_spec.rb +58 -35
  180. data/spec/unit/provider/remote_file/local_file_spec.rb +23 -0
  181. data/spec/unit/provider/service/solaris_smf_service_spec.rb +13 -13
  182. data/spec/unit/resource/mount_spec.rb +0 -1
  183. data/spec/unit/resource/remote_file_spec.rb +29 -0
  184. data/spec/unit/resource_spec.rb +1 -1
  185. data/spec/unit/run_context_spec.rb +7 -0
  186. data/spec/unit/run_lock_spec.rb +98 -0
  187. data/spec/unit/version_constraint_spec.rb +1 -1
  188. metadata +166 -153
  189. data/distro/common/html/_static/chef.css +0 -507
  190. data/distro/common/html/_static/chef_logo.png +0 -0
  191. data/lib/chef/checksum/storage.rb +0 -18
  192. data/lib/chef/checksum/storage/filesystem.rb +0 -56
  193. data/spec/unit/checksum/storage/filesystem_spec.rb +0 -70
@@ -1,4 +1,6 @@
1
- .TH "CHEF-SOLO" "8" "Chef 11.10.0" "" "chef-solo"
1
+ .\" Man page generated from reStructuredText.
2
+ .
3
+ .TH "CHEF-SOLO" "8" "Chef 11.12.0" "" "chef-solo"
2
4
  .SH NAME
3
5
  chef-solo \- The man page for the chef-solo command line tool.
4
6
  .
@@ -28,10 +30,8 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
28
30
  .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
29
31
  .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
30
32
  ..
31
- .\" Man page generated from reStructuredText.
32
- .
33
33
  .sp
34
- chef\-solo is an open source version of the chef\-client that allows using cookbooks with nodes without requiring access to a server. chef\-solo runs locally and requires that a cookbook (and any of its dependencies) be on the same physical disk as the node. chef\-solo is a limited\-functionality version of the chef\-client and \fBdoes not support\fP the following:
34
+ chef\-solo is an open source version of the chef\-client that allows using cookbooks with nodes without requiring access to a Chef server\&. chef\-solo runs locally and requires that a cookbook (and any of its dependencies) be on the same physical disk as the node. chef\-solo is a limited\-functionality version of the chef\-client and \fBdoes not support\fP the following:
35
35
  .INDENT 0.0
36
36
  .IP \(bu 2
37
37
  Node data storage
@@ -47,16 +47,27 @@ Authentication or authorization
47
47
  Persistent attributes
48
48
  .UNINDENT
49
49
  .sp
50
- The chef\-solo executable can be run as a command\-line tool.
50
+ \fBNOTE:\fP
51
+ .INDENT 0.0
52
+ .INDENT 3.5
53
+ chef\-solo can be run as a daemon.
54
+ .UNINDENT
55
+ .UNINDENT
56
+ .sp
57
+ The chef\-solo executable is run as a command\-line tool.
51
58
  .SH OPTIONS
52
59
  .sp
53
60
  This command has the following syntax:
61
+ .INDENT 0.0
62
+ .INDENT 3.5
54
63
  .sp
55
64
  .nf
56
65
  .ft C
57
66
  chef\-solo OPTION VALUE OPTION VALUE ...
58
67
  .ft P
59
68
  .fi
69
+ .UNINDENT
70
+ .UNINDENT
60
71
  .sp
61
72
  This command has the following options:
62
73
  .INDENT 0.0
@@ -65,20 +76,20 @@ This command has the following options:
65
76
  The configuration file to use.
66
77
  .TP
67
78
  .B \fB\-d\fP, \fB\-\-daemonize\fP
68
- Indicates that the executable will be run as a daemon. This option is only available on machines that run in UNIX or Linux environments. For machines that are running Microsoft Windows that require similar functionality, use the \fBchef\-client::service\fP recipe in the \fBchef\-client\fP cookbook: \fI\%http://community.opscode.com/cookbooks/chef-client\fP. This will install a chef\-client service under Microsoft Windows using the Windows Service Wrapper.
79
+ Indicates that the executable will be run as a daemon. This option is only available on machines that run in UNIX or Linux environments. For machines that are running Microsoft Windows that require similar functionality, use the \fBchef\-client::service\fP recipe in the \fBchef\-client\fP cookbook: \fI\%http://community.opscode.com/cookbooks/chef\-client\fP\&. This will install a chef\-client service under Microsoft Windows using the Windows Service Wrapper\&.
69
80
  .TP
70
81
  .B \fB\-E ENVIRONMENT_NAME\fP, \fB\-\-environment ENVIRONMENT_NAME\fP
71
82
  The name of the environment.
72
83
  .TP
73
84
  .B \fB\-f\fP, \fB\-\-[no\-]fork\fP
74
- Indicates that a chef\-client run will be contained in a secondary process with dedicated RAM. When the chef\-client run is complete the RAM will be returned to the master process. This option helps ensure that a chef\-client will use a steady amount of RAM over time because the master process will not run recipes. This option will also help prevent memory leaks (such as those that can be introduced by the code contained within a poorly designed cookbook). Use \fB\-\-no\-fork\fP to disable running the chef\-client in fork node. Default value: \fB\-\-fork\fP.
85
+ Indicates that a chef\-client run will be contained in a secondary process with dedicated RAM. When the chef\-client run is complete the RAM will be returned to the master process. This option helps ensure that a chef\-client will use a steady amount of RAM over time because the master process will not run recipes. This option will also help prevent memory leaks (such as those that can be introduced by the code contained within a poorly designed cookbook). Use \fB\-\-no\-fork\fP to disable running the chef\-client in fork node. Default value: \fB\-\-fork\fP\&.
75
86
  .TP
76
87
  .B \fB\-F FORMAT\fP, \fB\-\-format FORMAT\fP
77
- The output format: \fBdoc\fP (default) or \fBmin\fP.
88
+ The output format: \fBdoc\fP (default) or \fBmin\fP\&.
78
89
  .sp
79
90
  Use \fBdoc\fP to print the progress of the chef\-client run using full strings that display a summary of updates as they occur.
80
91
  .sp
81
- Use \fBmin\fP to print the progress of the chef\-client run using single characters. A summary of updates is printed at the end of the chef\-client run. A dot (\fB.\fP) is printed for events that do not have meaningful status information, such as loading a file or synchronizing a cookbook. For resources, a dot (\fB.\fP) is printed when the resource is up to date, an \fBS\fP is printed when the resource is skipped by \fBnot_if\fP or \fBonly_if\fP, and a \fBU\fP is printed when the resource is updated.
92
+ Use \fBmin\fP to print the progress of the chef\-client run using single characters. A summary of updates is printed at the end of the chef\-client run. A dot (\fB\&.\fP) is printed for events that do not have meaningful status information, such as loading a file or synchronizing a cookbook. For resources, a dot (\fB\&.\fP) is printed when the resource is up to date, an \fBS\fP is printed when the resource is skipped by \fBnot_if\fP or \fBonly_if\fP, and a \fBU\fP is printed when the resource is updated.
82
93
  .sp
83
94
  Other formatting options are available when those formatters are configured in the client.rb file using the \fBadd_formatter\fP option.
84
95
  .TP
@@ -107,7 +118,7 @@ The level of logging that will be stored in a log file.
107
118
  The location in which log file output files will be saved. If this location is set to something other than \fBSTDOUT\fP, standard output logging will still be performed (otherwise there would be no output other than to a file). This is recommended when starting any executable as a daemon.
108
119
  .TP
109
120
  .B \fB\-\-[no\-]color\fP
110
- Indicates whether colored output will be used. Default setting: \fB\-\-color\fP.
121
+ Indicates whether colored output will be used. Default setting: \fB\-\-color\fP\&.
111
122
  .TP
112
123
  .B \fB\-N NODE_NAME\fP, \fB\-\-node\-name NODE_NAME\fP
113
124
  The name of the node.
@@ -125,7 +136,7 @@ A number (in seconds) to add to the \fBinterval\fP that is used to determine the
125
136
  The user that owns a process. This is required when starting any executable as a daemon.
126
137
  .TP
127
138
  .B \fB\-v\fP, \fB\-\-version\fP
128
- The version of the chef\-client.
139
+ The version of the chef\-client\&.
129
140
  .TP
130
141
  .B \fB\-W\fP, \fB\-\-why\-run\fP
131
142
  Indicates that the executable will be run in why\-run mode, which is a type of chef\-client run that does everything except modify the system. Use why\-run mode to understand why the chef\-client makes the decisions that it makes and to learn more about the current and proposed state of the system.
@@ -133,34 +144,44 @@ Indicates that the executable will be run in why\-run mode, which is a type of c
133
144
  .SH EXAMPLES
134
145
  .sp
135
146
  \fBUse a URL\fP
147
+ .INDENT 0.0
148
+ .INDENT 3.5
136
149
  .sp
137
150
  .nf
138
151
  .ft C
139
152
  $ chef\-solo \-c ~/solo.rb \-j ~/node.json \-r http://www.example.com/chef\-solo.tar.gz
140
153
  .ft P
141
154
  .fi
155
+ .UNINDENT
156
+ .UNINDENT
142
157
  .sp
143
- where \fB\-r\fP uses the \fBremote_file\fP resource to retrieve the tar.gz archive into the \fBfile_cache_path\fP, and then extract it to \fBcookbooks_path\fP.
158
+ The tar.gz archived into the \fBfile_cache_path\fP, and then extracted to \fBcookbooks_path\fP\&.
144
159
  .sp
145
160
  \fBUse a directory\fP
161
+ .INDENT 0.0
162
+ .INDENT 3.5
146
163
  .sp
147
164
  .nf
148
165
  .ft C
149
166
  $ chef\-solo \-c ~/solo.rb \-j ~/node.json
150
167
  .ft P
151
168
  .fi
169
+ .UNINDENT
170
+ .UNINDENT
152
171
  .sp
153
- where the \fB\-r URL\fP option is not used. chef\-solo will look in the solo.rb file to determine the directory in which cookbooks are located.
172
+ chef\-solo will look in the solo.rb file to determine the directory in which cookbooks are located.
154
173
  .sp
155
174
  \fBUse a URL for cookbook and JSON data\fP
175
+ .INDENT 0.0
176
+ .INDENT 3.5
156
177
  .sp
157
178
  .nf
158
179
  .ft C
159
180
  $ chef\-solo \-c ~/solo.rb \-j http://www.example.com/node.json \-r http://www.example.com/chef\-solo.tar.gz
160
181
  .ft P
161
182
  .fi
162
- .sp
163
- where \fB\-r\fP corresponds to \fBrecipe_url\fP and \fB\-j\fP corresponds to \fBjson_attribs\fP, both of which are configuration options in solo.rb.
183
+ .UNINDENT
184
+ .UNINDENT
164
185
  .SH AUTHOR
165
186
  Chef
166
187
  .\" Generated by docutils manpage writer.
@@ -35,20 +35,6 @@ class Chef::Application
35
35
 
36
36
  @chef_client = nil
37
37
  @chef_client_json = nil
38
- trap("INT") do
39
- Chef::Application.fatal!("SIGINT received, stopping", 2)
40
- end
41
-
42
- unless Chef::Platform.windows?
43
- trap("QUIT") do
44
- Chef::Log.info("SIGQUIT received, call stack:\n " + caller.join("\n "))
45
- end
46
-
47
- trap("HUP") do
48
- Chef::Log.info("SIGHUP received, reconfiguring")
49
- reconfigure
50
- end
51
- end
52
38
 
53
39
  # Always switch to a readable directory. Keeps subsequent Dir.chdir() {}
54
40
  # from failing due to permissions when launched as a less privileged user.
@@ -62,11 +48,30 @@ class Chef::Application
62
48
 
63
49
  # Get this party started
64
50
  def run
51
+ setup_signal_handlers
65
52
  reconfigure
66
53
  setup_application
67
54
  run_application
68
55
  end
69
56
 
57
+ def setup_signal_handlers
58
+ trap("INT") do
59
+ Chef::Application.fatal!("SIGINT received, stopping", 2)
60
+ end
61
+
62
+ unless Chef::Platform.windows?
63
+ trap("QUIT") do
64
+ Chef::Log.info("SIGQUIT received, call stack:\n " + caller.join("\n "))
65
+ end
66
+
67
+ trap("HUP") do
68
+ Chef::Log.info("SIGHUP received, reconfiguring")
69
+ reconfigure
70
+ end
71
+ end
72
+ end
73
+
74
+
70
75
  # Parse configuration (options and config file)
71
76
  def configure_chef
72
77
  parse_options
@@ -219,6 +219,11 @@ class Chef::Application::Client < Chef::Application
219
219
  :long => "--config-file-jail PATH",
220
220
  :description => "Directory under which config files are allowed to be loaded (no client.rb or knife.rb outside this path will be loaded)."
221
221
 
222
+ option :run_lock_timeout,
223
+ :long => "--run-lock-timeout SECONDS",
224
+ :description => "Set maximum duration to wait for another client run to finish, default is indefinitely.",
225
+ :proc => lambda { |s| s.to_i }
226
+
222
227
  if Chef::Platform.windows?
223
228
  option :fatal_windows_admin_check,
224
229
  :short => "-A",
@@ -165,6 +165,11 @@ class Chef::Application::Solo < Chef::Application
165
165
  :long => '--environment ENVIRONMENT',
166
166
  :description => 'Set the Chef Environment on the node'
167
167
 
168
+ option :run_lock_timeout,
169
+ :long => "--run-lock-timeout SECONDS",
170
+ :description => "Set maximum duration to wait for another client run to finish, default is indefinitely.",
171
+ :proc => lambda { |s| s.to_i }
172
+
168
173
  attr_reader :chef_client_json
169
174
 
170
175
  def initialize
@@ -112,6 +112,9 @@ class Chef
112
112
  :service_name => @service_name,
113
113
  :display_name => @service_display_name,
114
114
  :description => @service_description,
115
+ # Prior to 0.8.5, win32-service creates interactive services by default,
116
+ # and we don't want that, so we need to override the service type.
117
+ :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
115
118
  :start_type => ::Win32::Service::SERVICE_AUTO_START,
116
119
  :binary_path_name => cmd
117
120
  )
@@ -23,6 +23,7 @@ require 'chef/chef_fs/file_pattern'
23
23
  require 'chef/chef_fs/file_system'
24
24
  require 'chef/chef_fs/file_system/not_found_error'
25
25
  require 'chef/chef_fs/file_system/memory_root'
26
+ require 'fileutils'
26
27
 
27
28
  class Chef
28
29
  module ChefFS
@@ -43,7 +44,11 @@ class Chef
43
44
  @memory_store.create_dir(path, name, *options)
44
45
  else
45
46
  with_dir(path) do |parent|
46
- parent.create_child(chef_fs_filename(path + [name]), nil)
47
+ begin
48
+ parent.create_child(chef_fs_filename(path + [name]), nil)
49
+ rescue Chef::ChefFS::FileSystem::AlreadyExistsError => e
50
+ raise ChefZero::DataStore::DataAlreadyExistsError.new(to_zero_path(e.entry), e)
51
+ end
47
52
  end
48
53
  end
49
54
  end
@@ -61,7 +66,11 @@ class Chef
61
66
  end
62
67
 
63
68
  with_dir(path) do |parent|
64
- parent.create_child(chef_fs_filename(path + [name]), data)
69
+ begin
70
+ parent.create_child(chef_fs_filename(path + [name]), data)
71
+ rescue Chef::ChefFS::FileSystem::AlreadyExistsError => e
72
+ raise ChefZero::DataStore::DataAlreadyExistsError.new(to_zero_path(e.entry), e)
73
+ end
65
74
  end
66
75
  end
67
76
  end
@@ -82,7 +91,13 @@ class Chef
82
91
  with_entry(path) do |entry|
83
92
  if path[0] == 'cookbooks' && path.length == 3
84
93
  # get /cookbooks/NAME/version
85
- result = entry.chef_object.to_hash
94
+ result = nil
95
+ begin
96
+ result = entry.chef_object.to_hash
97
+ rescue Chef::ChefFS::FileSystem::NotFoundError => e
98
+ raise ChefZero::DataStore::DataNotFoundError.new(to_zero_path(e.entry), e)
99
+ end
100
+
86
101
  result.each_pair do |key, value|
87
102
  if value.is_a?(Array)
88
103
  value.each do |file|
@@ -102,7 +117,11 @@ class Chef
102
117
  JSON.pretty_generate(result)
103
118
 
104
119
  else
105
- entry.read
120
+ begin
121
+ entry.read
122
+ rescue Chef::ChefFS::FileSystem::NotFoundError => e
123
+ raise ChefZero::DataStore::DataNotFoundError.new(to_zero_path(e.entry), e)
124
+ end
106
125
  end
107
126
  end
108
127
  end
@@ -121,7 +140,12 @@ class Chef
121
140
  write_cookbook(path, data, *options)
122
141
  else
123
142
  with_dir(path[0..-2]) do |parent|
124
- parent.create_child(chef_fs_filename(path), data)
143
+ child = parent.child(chef_fs_filename(path))
144
+ if child.exists?
145
+ child.write(data)
146
+ else
147
+ parent.create_child(chef_fs_filename(path), data)
148
+ end
125
149
  end
126
150
  end
127
151
  end
@@ -132,10 +156,14 @@ class Chef
132
156
  @memory_store.delete(path)
133
157
  else
134
158
  with_entry(path) do |entry|
135
- if path[0] == 'cookbooks' && path.length >= 3
136
- entry.delete(true)
137
- else
138
- entry.delete(false)
159
+ begin
160
+ if path[0] == 'cookbooks' && path.length >= 3
161
+ entry.delete(true)
162
+ else
163
+ entry.delete(false)
164
+ end
165
+ rescue Chef::ChefFS::FileSystem::NotFoundError => e
166
+ raise ChefZero::DataStore::DataNotFoundError.new(to_zero_path(e.entry), e)
139
167
  end
140
168
  end
141
169
  end
@@ -146,7 +174,11 @@ class Chef
146
174
  @memory_store.delete_dir(path, *options)
147
175
  else
148
176
  with_entry(path) do |entry|
149
- entry.delete(options.include?(:recursive))
177
+ begin
178
+ entry.delete(options.include?(:recursive))
179
+ rescue Chef::ChefFS::FileSystem::NotFoundError => e
180
+ raise ChefZero::DataStore::DataNotFoundError.new(to_zero_path(e.entry), e)
181
+ end
150
182
  end
151
183
  end
152
184
  end
@@ -172,10 +204,16 @@ class Chef
172
204
 
173
205
  elsif path[0] == 'cookbooks' && path.length == 2
174
206
  if Chef::Config.versioned_cookbooks
175
- # list /cookbooks/name = filter /cookbooks/name-version down to name
176
- entry.children.map { |child| split_name_version(child.name) }.
177
- select { |name, version| name == path[1] }.
178
- map { |name, version| version }.to_a
207
+ result = with_entry([ 'cookbooks' ]) do |entry|
208
+ # list /cookbooks/name = filter /cookbooks/name-version down to name
209
+ entry.children.map { |child| split_name_version(child.name) }.
210
+ select { |name, version| name == path[1] }.
211
+ map { |name, version| version }
212
+ end
213
+ if result.empty?
214
+ raise ChefZero::DataStore::DataNotFoundError.new(path)
215
+ end
216
+ result
179
217
  else
180
218
  # list /cookbooks/name = <single version>
181
219
  version = get_single_cookbook_version(path)
@@ -186,12 +224,12 @@ class Chef
186
224
  with_entry(path) do |entry|
187
225
  begin
188
226
  entry.children.map { |c| zero_filename(c) }.sort
189
- rescue Chef::ChefFS::FileSystem::NotFoundError
227
+ rescue Chef::ChefFS::FileSystem::NotFoundError => e
190
228
  # /cookbooks, /data, etc. never return 404
191
229
  if path_always_exists?(path)
192
230
  []
193
231
  else
194
- raise
232
+ raise ChefZero::DataStore::DataNotFoundError.new(to_zero_path(e.entry), e)
195
233
  end
196
234
  end
197
235
  end
@@ -223,12 +261,13 @@ class Chef
223
261
  end
224
262
 
225
263
  def write_cookbook(path, data, *options)
226
- # Create a little Chef::ChefFS memory filesystem with the data
227
264
  if Chef::Config.versioned_cookbooks
228
- cookbook_path = "cookbooks/#{path[1]}-#{path[2]}"
265
+ cookbook_path = File.join('cookbooks', "#{path[1]}-#{path[2]}")
229
266
  else
230
- cookbook_path = "cookbooks/#{path[1]}"
267
+ cookbook_path = File.join('cookbooks', path[1])
231
268
  end
269
+
270
+ # Create a little Chef::ChefFS memory filesystem with the data
232
271
  cookbook_fs = Chef::ChefFS::FileSystem::MemoryRoot.new('uploading')
233
272
  cookbook = JSON.parse(data, :create_additions => false)
234
273
  cookbook.each_pair do |key, value|
@@ -236,15 +275,22 @@ class Chef
236
275
  value.each do |file|
237
276
  if file.is_a?(Hash) && file.has_key?('checksum')
238
277
  file_data = @memory_store.get(['file_store', 'checksums', file['checksum']])
239
- cookbook_fs.add_file("#{cookbook_path}/#{file['path']}", file_data)
278
+ cookbook_fs.add_file(File.join(cookbook_path, file['path']), file_data)
240
279
  end
241
280
  end
242
281
  end
243
282
  end
244
283
 
245
- # Use the copy/diff algorithm to copy it down so we don't destroy
246
- # chefignored data. This is terribly un-thread-safe.
247
- Chef::ChefFS::FileSystem.copy_to(Chef::ChefFS::FilePattern.new("/#{cookbook_path}"), cookbook_fs, chef_fs, nil, {:purge => true})
284
+ # Create the .uploaded-cookbook-version.json
285
+ cookbooks = chef_fs.child('cookbooks')
286
+ if !cookbooks.exists?
287
+ cookbooks = chef_fs.create_child('cookbooks')
288
+ end
289
+ # We are calling a cookbooks-specific API, so get multiplexed_dirs out of the way if it is there
290
+ if cookbooks.respond_to?(:multiplexed_dirs)
291
+ cookbooks = cookbooks.write_dir
292
+ end
293
+ cookbooks.write_cookbook(cookbook_path, data, cookbook_fs)
248
294
  end
249
295
 
250
296
  def split_name_version(entry_name)
@@ -343,8 +389,10 @@ class Chef
343
389
  end
344
390
 
345
391
  def with_dir(path)
392
+ # Do not automatically create data bags
393
+ create = !(path[0] == 'data' && path.size >= 2)
346
394
  begin
347
- yield get_dir(_to_chef_fs_path(path), true)
395
+ yield get_dir(_to_chef_fs_path(path), create)
348
396
  rescue Chef::ChefFS::FileSystem::NotFoundError => e
349
397
  raise ChefZero::DataStore::DataNotFoundError.new(to_zero_path(e.entry), e)
350
398
  end
@@ -44,11 +44,17 @@ class Chef
44
44
  end
45
45
 
46
46
  loader.load_cookbooks
47
- return loader.cookbook_version
48
- rescue
49
- Chef::Log.error("Could not read #{path_for_printing} into a Chef object: #{$!}")
47
+ cb = loader.cookbook_version
48
+ if !cb
49
+ Chef::Log.error("Cookbook #{file_path} empty.")
50
+ raise "Cookbook #{file_path} empty."
51
+ end
52
+ cb
53
+ rescue => e
54
+ Chef::Log.error("Could not read #{path_for_printing} into a Chef object: #{e}")
55
+ Chef::Log.error(e.backtrace.join("\n"))
56
+ raise
50
57
  end
51
- nil
52
58
  end
53
59
 
54
60
  def children
@@ -66,6 +72,8 @@ class Chef
66
72
  if is_dir
67
73
  # Only the given directories will be uploaded.
68
74
  return CookbookDir::COOKBOOK_SEGMENT_INFO.keys.include?(name.to_sym) && name != 'root_files'
75
+ elsif name == Chef::Cookbook::CookbookVersionLoader::UPLOADED_COOKBOOK_VERSION_FILE
76
+ return false
69
77
  end
70
78
  super(name, is_dir)
71
79
  end
@@ -81,6 +89,14 @@ class Chef
81
89
  self.class.canonical_cookbook_name(entry_name)
82
90
  end
83
91
 
92
+ def uploaded_cookbook_version_path
93
+ File.join(file_path, Chef::Cookbook::CookbookVersionLoader::UPLOADED_COOKBOOK_VERSION_FILE)
94
+ end
95
+
96
+ def can_upload?
97
+ File.exists?(uploaded_cookbook_version_path) || children.size > 0
98
+ end
99
+
84
100
  protected
85
101
 
86
102
  def make_child(child_name)