chef 11.10.0.alpha.1 → 11.10.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/README.md +57 -36
  2. data/distro/common/html/chef-client.8.html +4 -4
  3. data/distro/common/html/chef-expander.8.html +4 -4
  4. data/distro/common/html/chef-expanderctl.8.html +4 -4
  5. data/distro/common/html/chef-server-webui.8.html +4 -4
  6. data/distro/common/html/chef-server.8.html +4 -4
  7. data/distro/common/html/chef-shell.1.html +4 -4
  8. data/distro/common/html/chef-solo.8.html +4 -4
  9. data/distro/common/html/chef-solr.8.html +5 -5
  10. data/distro/common/html/knife-bootstrap.1.html +4 -4
  11. data/distro/common/html/knife-client.1.html +4 -4
  12. data/distro/common/html/knife-configure.1.html +4 -4
  13. data/distro/common/html/knife-cookbook-site.1.html +4 -4
  14. data/distro/common/html/knife-cookbook.1.html +4 -4
  15. data/distro/common/html/knife-data-bag.1.html +4 -4
  16. data/distro/common/html/knife-environment.1.html +4 -4
  17. data/distro/common/html/knife-exec.1.html +4 -4
  18. data/distro/common/html/knife-index.1.html +4 -4
  19. data/distro/common/html/knife-node.1.html +4 -4
  20. data/distro/common/html/knife-role.1.html +4 -4
  21. data/distro/common/html/knife-search.1.html +4 -4
  22. data/distro/common/html/knife-ssh.1.html +4 -4
  23. data/distro/common/html/knife-status.1.html +4 -4
  24. data/distro/common/html/knife-tag.1.html +4 -4
  25. data/distro/common/html/knife.1.html +4 -4
  26. data/distro/common/man/man1/knife-bootstrap.1 +58 -64
  27. data/distro/common/man/man1/knife-client.1 +19 -22
  28. data/distro/common/man/man1/knife-configure.1 +37 -46
  29. data/distro/common/man/man1/knife-cookbook-site.1 +14 -17
  30. data/distro/common/man/man1/knife-cookbook.1 +15 -18
  31. data/distro/common/man/man1/knife-data-bag.1 +14 -17
  32. data/distro/common/man/man1/knife-delete.1 +38 -47
  33. data/distro/common/man/man1/knife-deps.1 +39 -48
  34. data/distro/common/man/man1/knife-diff.1 +43 -52
  35. data/distro/common/man/man1/knife-download.1 +47 -53
  36. data/distro/common/man/man1/knife-edit.1 +32 -41
  37. data/distro/common/man/man1/knife-environment.1 +14 -17
  38. data/distro/common/man/man1/knife-exec.1 +52 -61
  39. data/distro/common/man/man1/knife-index-rebuild.1 +1 -61
  40. data/distro/common/man/man1/knife-list.1 +47 -59
  41. data/distro/common/man/man1/knife-node.1 +15 -18
  42. data/distro/common/man/man1/knife-raw.1 +28 -46
  43. data/distro/common/man/man1/knife-recipe-list.1 +1 -61
  44. data/distro/common/man/man1/knife-role.1 +19 -25
  45. data/distro/common/man/man1/knife-search.1 +53 -62
  46. data/distro/common/man/man1/knife-show.1 +36 -28
  47. data/distro/common/man/man1/knife-ssh.1 +55 -61
  48. data/distro/common/man/man1/knife-status.1 +34 -43
  49. data/distro/common/man/man1/knife-tag.1 +14 -17
  50. data/distro/common/man/man1/knife-upload.1 +47 -56
  51. data/distro/common/man/man1/knife-user.1 +17 -20
  52. data/distro/common/man/man1/knife-xargs.1 +60 -69
  53. data/lib/chef/application.rb +3 -1
  54. data/lib/chef/application/windows_service.rb +0 -1
  55. data/lib/chef/client.rb +41 -152
  56. data/lib/chef/config.rb +19 -23
  57. data/lib/chef/data_bag.rb +1 -1
  58. data/lib/chef/data_bag_item.rb +1 -1
  59. data/lib/chef/exceptions.rb +8 -0
  60. data/lib/chef/formatters/doc.rb +15 -0
  61. data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +2 -1
  62. data/lib/chef/http.rb +18 -8
  63. data/lib/chef/http/authenticator.rb +4 -0
  64. data/lib/chef/http/cookie_manager.rb +3 -0
  65. data/lib/chef/http/decompressor.rb +4 -0
  66. data/lib/chef/http/json_input.rb +4 -0
  67. data/lib/chef/http/json_output.rb +4 -0
  68. data/lib/chef/http/validate_content_length.rb +94 -0
  69. data/lib/chef/knife.rb +0 -1
  70. data/lib/chef/knife/configure.rb +6 -6
  71. data/lib/chef/knife/cookbook_create.rb +2 -2
  72. data/lib/chef/knife/core/subcommand_loader.rb +49 -3
  73. data/lib/chef/knife/ssh.rb +34 -4
  74. data/lib/chef/mixin/path_sanity.rb +1 -0
  75. data/lib/chef/monologger.rb +1 -2
  76. data/lib/chef/node.rb +7 -0
  77. data/lib/chef/policy_builder.rb +49 -0
  78. data/lib/chef/policy_builder/expand_node_object.rb +230 -0
  79. data/lib/chef/policy_builder/policyfile.rb +338 -0
  80. data/lib/chef/provider/file.rb +15 -5
  81. data/lib/chef/provider/group.rb +6 -2
  82. data/lib/chef/provider/group/windows.rb +12 -2
  83. data/lib/chef/provider/http_request.rb +3 -2
  84. data/lib/chef/provider/package.rb +1 -0
  85. data/lib/chef/provider/package/aix.rb +1 -1
  86. data/lib/chef/provider/service/debian.rb +7 -2
  87. data/lib/chef/resource/file.rb +8 -1
  88. data/lib/chef/resource/package.rb +9 -0
  89. data/lib/chef/resource/service.rb +0 -1
  90. data/lib/chef/rest.rb +2 -0
  91. data/lib/chef/run_context.rb +1 -1
  92. data/lib/chef/util/file_edit.rb +1 -1
  93. data/lib/chef/util/windows/net_group.rb +7 -6
  94. data/lib/chef/version.rb +1 -1
  95. data/lib/chef/win32/version.rb +31 -18
  96. data/spec/data/cookbooks/preseed/templates/default/preseed-template-variables.seed +1 -0
  97. data/spec/functional/resource/file_spec.rb +0 -1
  98. data/spec/functional/resource/group_spec.rb +96 -16
  99. data/spec/functional/resource/package_spec.rb +17 -0
  100. data/spec/functional/resource/user_spec.rb +2 -2
  101. data/spec/functional/win32/versions_spec.rb +39 -0
  102. data/spec/integration/client/client_spec.rb +27 -28
  103. data/spec/spec_helper.rb +2 -0
  104. data/spec/support/platform_helpers.rb +7 -1
  105. data/spec/support/shared/functional/file_resource.rb +83 -43
  106. data/spec/unit/application_spec.rb +7 -5
  107. data/spec/unit/client_spec.rb +10 -3
  108. data/spec/unit/config_spec.rb +0 -30
  109. data/spec/unit/cookbook_spec.rb +1 -0
  110. data/spec/unit/data_bag_item_spec.rb +8 -0
  111. data/spec/unit/data_bag_spec.rb +6 -0
  112. data/spec/unit/http_spec.rb +48 -0
  113. data/spec/unit/knife/core/subcommand_loader_spec.rb +77 -1
  114. data/spec/unit/knife/ssh_spec.rb +107 -0
  115. data/spec/unit/mixin/path_sanity_spec.rb +6 -0
  116. data/spec/unit/mixin/securable_spec.rb +77 -3
  117. data/spec/unit/monologger_spec.rb +45 -0
  118. data/spec/unit/node_spec.rb +16 -0
  119. data/spec/unit/policy_builder/expand_node_object_spec.rb +320 -0
  120. data/spec/unit/policy_builder/policyfile_spec.rb +399 -0
  121. data/spec/unit/policy_builder_spec.rb +26 -0
  122. data/spec/unit/provider/deploy_spec.rb +3 -0
  123. data/spec/unit/provider/group/windows_spec.rb +1 -0
  124. data/spec/unit/provider/http_request_spec.rb +23 -1
  125. data/spec/unit/provider/service/debian_service_spec.rb +50 -19
  126. data/spec/unit/recipe_spec.rb +4 -0
  127. data/spec/unit/resource/package_spec.rb +5 -0
  128. data/spec/unit/rest_spec.rb +375 -278
  129. data/spec/unit/run_context_spec.rb +4 -0
  130. metadata +96 -59
  131. checksums.yaml +0 -7
@@ -33,16 +33,35 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
33
33
  .sp
34
34
  The \fBknife upload\fP subcommand is used to upload roles, cookbooks, environments, and data bags to the server from the current working directory in the chef\-repo. This subcommand is often used in conjunction with \fBknife diff\fP, which can be used to see exactly what changes will be uploaded, and then \fBknife download\fP, which does the opposite of \fBknife upload\fP.
35
35
  .sp
36
- \fBCommon Options\fP
36
+ \fBSyntax\fP
37
+ .sp
38
+ This argument has the following syntax:
39
+ .sp
40
+ .nf
41
+ .ft C
42
+ $ knife upload [PATTERN...] (options)
43
+ .ft P
44
+ .fi
45
+ .sp
46
+ \fBOptions\fP
37
47
  .sp
38
- The following options can be run with all Knife sub\-commands and plug\-ins:
48
+ This subcommand has the following options:
39
49
  .INDENT 0.0
40
50
  .TP
41
- .B \fB\-c CONFIG\fP, \fB\-\-config CONFIG\fP
51
+ .B \fB\-c CONFIG_FILE\fP, \fB\-\-config CONFIG_FILE\fP
42
52
  The configuration file to use.
43
53
  .TP
44
- .B \fB\-\-color\fP
45
- Indicates that colored output will be used.
54
+ .B \fB\-\-chef\-repo\-path PATH\fP
55
+ The path to the chef\-repo. This setting will override the default path to the chef\-repo. Default: same as specified by \fBchef_repo_path\fP in config.rb.
56
+ .TP
57
+ .B \fB\-\-chef\-zero\-port PORT\fP
58
+ The port on which chef\-zero will listen.
59
+ .TP
60
+ .B \fB\-\-[no\-]color\fP
61
+ Indicates whether colored output will be used.
62
+ .TP
63
+ .B \fB\-\-concurrency\fP
64
+ The number of allowed concurrent connections. Default: \fB10\fP.
46
65
  .TP
47
66
  .B \fB\-d\fP, \fB\-\-disable\-editing\fP
48
67
  Indicates that $EDITOR will not be opened; data will be accepted as\-is.
@@ -50,33 +69,45 @@ Indicates that $EDITOR will not be opened; data will be accepted as\-is.
50
69
  .B \fB\-\-defaults\fP
51
70
  Indicates that Knife will use the default value, instead of asking a user to provide one.
52
71
  .TP
72
+ .B \fB\-\-[no\-]diff\fP
73
+ Indicates that only new and modified files will be uploaded. Set to \fBfalse\fP to upload all files. Default: \fBtrue\fP.
74
+ .TP
53
75
  .B \fB\-e EDITOR\fP, \fB\-\-editor EDITOR\fP
54
76
  The $EDITOR that is used for all interactive commands.
55
77
  .TP
56
78
  .B \fB\-E ENVIRONMENT\fP, \fB\-\-environment ENVIRONMENT\fP
57
79
  The name of the environment. When this option is added to a command, the command will run only against the named environment.
58
80
  .TP
59
- .B \fB\-f FILE_NAME\fP, \fB\-\-file FILE_NAME\fP
60
- Indicates that the private key will be saved to a specified file name.
61
- .TP
62
81
  .B \fB\-F FORMAT\fP, \fB\-\-format FORMAT\fP
63
82
  The output format: \fBsummary\fP (default), \fBtext\fP, \fBjson\fP, \fByaml\fP, and \fBpp\fP.
64
83
  .TP
84
+ .B \fB\-\-[no\-]force\fP
85
+ Use \fB\-\-force\fP to upload roles, cookbooks, etc. even if the file in the directory is identical (by default, no \fBPOST\fP or \fBPUT\fP is performed unless an actual change would be made). Default: \fB\-\-no\-force\fP.
86
+ .TP
87
+ .B \fB\-\-[no\-]freeze\fP
88
+ Indicates that a cookbook cannot be modified; any changes to this cookbook must be included as a new version. Only the \fB\-\-force\fP option can override this setting. Default: \fBfalse\fP.
89
+ .TP
65
90
  .B \fB\-h\fP, \fB\-\-help\fP
66
91
  Shows help for the command.
67
92
  .TP
68
93
  .B \fB\-k KEY\fP, \fB\-\-key KEY\fP
69
94
  The private key that Knife will use to sign requests made by the API client to the server.
70
95
  .TP
71
- .B \fB\-\-no\-color\fP
72
- Indicates that color will not be used in the output.
73
- .TP
74
- .B \fB\-p PASSWORD\fP, \fB\-\-password PASSWORD\fP
75
- The user password.
96
+ .B \fB\-n\fP, \fB\-\-dry\-run\fP
97
+ Indicates that no action is taken and that results are only printed out. Default: \fBfalse\fP.
76
98
  .TP
77
99
  .B \fB\-\-print\-after\fP
78
100
  Indicates that data will be shown after a destructive operation.
79
101
  .TP
102
+ .B \fB\-\-[no\-]purge\fP
103
+ Use \fB\-\-purge\fP to delete roles, cookbooks, etc. from the server if their corresponding files do not exist in the chef\-repo. By default, such objects are left alone and NOT purged. Default: \fB\-\-no\-purge\fP.
104
+ .TP
105
+ .B \fB\-\-[no\-]recurse\fP
106
+ Use \fB\-\-no\-recurse\fP to disable uploading a directory recursively. Default: \fB\-\-recurse\fP.
107
+ .TP
108
+ .B \fB\-\-repo\-mode MODE\fP
109
+ The layout of the local chef\-repo. Possible values: \fBstatic\fP, \fBeverything\fP, or \fBhosted_everything\fP. Use \fBstatic\fP for just roles, environments, cookbooks, and data bags. By default, \fBeverything\fP and \fBhosted_everything\fP are dynamically selected depending on the server type. Default: \fBeverything\fP / \fBhosted_everything\fP.
110
+ .TP
80
111
  .B \fB\-s URL\fP, \fB\-\-server\-url URL\fP
81
112
  The URL for the server.
82
113
  .TP
@@ -91,49 +122,9 @@ Set for more verbose outputs. Use \fB\-VV\fP for maximum verbosity.
91
122
  .TP
92
123
  .B \fB\-y\fP, \fB\-\-yes\fP
93
124
  Indicates that the response to all confirmation prompts will be "Yes" (and that Knife will not ask for confirmation).
94
- .UNINDENT
95
- .sp
96
- \fBSyntax\fP
97
- .sp
98
- This argument has the following syntax:
99
- .sp
100
- .nf
101
- .ft C
102
- $ knife upload [PATTERN...] (options)
103
- .ft P
104
- .fi
105
- .sp
106
- \fBOptions\fP
107
- .sp
108
- This subcommand has the following options:
109
- .INDENT 0.0
110
- .TP
111
- .B \fB\-\-chef\-repo\-path PATH\fP
112
- The path to the chef\-repo. This setting will override the default path to the chef\-repo. Default: same as specified by \fBchef_repo_path\fP in config.rb.
113
- .TP
114
- .B \fB\-\-concurrency\fP
115
- The number of allowed concurrent connections. Default: \fB10\fP.
116
125
  .TP
117
- .B \fB\-\-[no\-]diff\fP
118
- Indicates that only new and modified files will be uploaded. Set to \fBfalse\fP to upload all files. Default: \fBtrue\fP.
119
- .TP
120
- .B \fB\-\-[no\-]force\fP
121
- Use \fB\-\-force\fP to upload roles, cookbooks, etc. even if the file in the directory is identical (by default, no \fBPOST\fP or \fBPUT\fP is performed unless an actual change would be made). Default: \fB\-\-no\-force\fP.
122
- .TP
123
- .B \fB\-\-[no\-]freeze\fP
124
- Indicates that a cookbook cannot be modified; any changes to this cookbook must be included as a new version. Only the \fB\-\-force\fP option can override this setting. Default: \fBfalse\fP.
125
- .TP
126
- .B \fB\-n\fP, \fB\-\-dry\-run\fP
127
- Indicates that no action is taken and that results are only printed out. Default: \fBfalse\fP.
128
- .TP
129
- .B \fB\-\-[no\-]purge\fP
130
- Use \fB\-\-purge\fP to delete roles, cookbooks, etc. from the server if their corresponding files do not exist in the chef\-repo. By default, such objects are left alone and NOT purged. Default: \fB\-\-no\-purge\fP.
131
- .TP
132
- .B \fB\-\-[no\-]recurse\fP
133
- Use \fB\-\-no\-recurse\fP to disable uploading a directory recursively. Default: \fB\-\-recurse\fP.
134
- .TP
135
- .B \fB\-\-repo\-mode MODE\fP
136
- The layout of the local chef\-repo. Possible values: \fBstatic\fP, \fBeverything\fP, or \fBhosted_everything\fP. Use \fBstatic\fP for just roles, environments, cookbooks, and data bags. By default, \fBeverything\fP and \fBhosted_everything\fP are dynamically selected depending on the server type. Default: \fBeverything\fP / \fBhosted_everything\fP.
126
+ .B \fB\-z\fP, \fB\-\-local\-mode\fP
127
+ Indicates that the chef\-client will be run in local mode, which allows all commands that work against the server to also work against the local chef\-repo.
137
128
  .UNINDENT
138
129
  .sp
139
130
  \fBExamples\fP
@@ -234,6 +225,6 @@ $ knife upload \(gaknife deps nodes/*.json\(ga
234
225
  .ft P
235
226
  .fi
236
227
  .SH AUTHOR
237
- Opscode
228
+ Chef
238
229
  .\" Generated by docutils manpage writer.
239
230
  .
@@ -45,14 +45,14 @@ $ knife user [ARGUMENT] (options)
45
45
  .fi
46
46
  .SH COMMON OPTIONS
47
47
  .sp
48
- The following options can be run with all Knife sub\-commands and plug\-ins:
48
+ The following options may be used with any of the arguments available to the \fBknife user\fP subcommand:
49
49
  .INDENT 0.0
50
50
  .TP
51
- .B \fB\-c CONFIG\fP, \fB\-\-config CONFIG\fP
52
- The configuration file to use.
51
+ .B \fB\-\-chef\-zero\-port PORT\fP
52
+ The port on which chef\-zero will listen.
53
53
  .TP
54
- .B \fB\-\-color\fP
55
- Indicates that colored output will be used.
54
+ .B \fB\-c CONFIG_FILE\fP, \fB\-\-config CONFIG_FILE\fP
55
+ The configuration file to use.
56
56
  .TP
57
57
  .B \fB\-d\fP, \fB\-\-disable\-editing\fP
58
58
  Indicates that $EDITOR will not be opened; data will be accepted as\-is.
@@ -66,9 +66,6 @@ The $EDITOR that is used for all interactive commands.
66
66
  .B \fB\-E ENVIRONMENT\fP, \fB\-\-environment ENVIRONMENT\fP
67
67
  The name of the environment. When this option is added to a command, the command will run only against the named environment.
68
68
  .TP
69
- .B \fB\-f FILE_NAME\fP, \fB\-\-file FILE_NAME\fP
70
- Indicates that the private key will be saved to a specified file name.
71
- .TP
72
69
  .B \fB\-F FORMAT\fP, \fB\-\-format FORMAT\fP
73
70
  The output format: \fBsummary\fP (default), \fBtext\fP, \fBjson\fP, \fByaml\fP, and \fBpp\fP.
74
71
  .TP
@@ -78,11 +75,8 @@ Shows help for the command.
78
75
  .B \fB\-k KEY\fP, \fB\-\-key KEY\fP
79
76
  The private key that Knife will use to sign requests made by the API client to the server.
80
77
  .TP
81
- .B \fB\-\-no\-color\fP
82
- Indicates that color will not be used in the output.
83
- .TP
84
- .B \fB\-p PASSWORD\fP, \fB\-\-password PASSWORD\fP
85
- The user password.
78
+ .B \fB\-\-[no\-]color\fP
79
+ Indicates whether colored output will be used.
86
80
  .TP
87
81
  .B \fB\-\-print\-after\fP
88
82
  Indicates that data will be shown after a destructive operation.
@@ -93,23 +87,26 @@ The URL for the server.
93
87
  .B \fB\-u USER\fP, \fB\-\-user USER\fP
94
88
  The user name used by Knife to sign requests made by the API client to the server. Authentication will fail if the user name does not match the private key.
95
89
  .TP
96
- .B \fB\-v\fP, \fB\-\-version\fP
97
- The version of the chef\-client.
98
- .TP
99
90
  .B \fB\-V\fP, \fB\-\-verbose\fP
100
91
  Set for more verbose outputs. Use \fB\-VV\fP for maximum verbosity.
101
92
  .TP
93
+ .B \fB\-v\fP, \fB\-\-version\fP
94
+ The version of the chef\-client.
95
+ .TP
102
96
  .B \fB\-y\fP, \fB\-\-yes\fP
103
97
  Indicates that the response to all confirmation prompts will be "Yes" (and that Knife will not ask for confirmation).
98
+ .TP
99
+ .B \fB\-z\fP, \fB\-\-local\-mode\fP
100
+ Indicates that the chef\-client will be run in local mode, which allows all commands that work against the server to also work against the local chef\-repo.
104
101
  .UNINDENT
105
102
  .SH CREATE
106
103
  .sp
107
104
  The \fBcreate\fP argument is used to create a user. This process will generate an RSA key pair for the named user. The public key will be stored on the server and the private key will be displayed on \fBSTDOUT\fP or written to a named file.
108
105
  .INDENT 0.0
109
106
  .IP \(bu 2
110
- For the user, the private key should be copied to the system as /etc/chef/client.pem.
107
+ For the user, the private key should be copied to the system as \fB/etc/chef/client.pem\fP.
111
108
  .IP \(bu 2
112
- For Knife, the private key is typically copied to ~/.chef/client_name.pem and referenced in the knife.rb configuration file.
109
+ For Knife, the private key is typically copied to \fB~/.chef/client_name.pem\fP and referenced in the knife.rb configuration file.
113
110
  .UNINDENT
114
111
  .sp
115
112
  \fBSyntax\fP
@@ -128,7 +125,7 @@ This argument has the following options:
128
125
  .INDENT 0.0
129
126
  .TP
130
127
  .B \fB\-a\fP, \fB\-\-admin\fP
131
- Indicates that a client will be created as an admin client. This is required when users of the open source server need to access the Chef Server API as an administrator. This option only works when used with the open source server and will have no effect when used with Hosted Chef or Private Chef.
128
+ Indicates that a client will be created as an admin client. This is required when users of the open source server need to access the Chef Server API as an administrator. This option only works when used with the open source server and will have no effect when used with Enterprise Chef.
132
129
  .TP
133
130
  .B \fB\-f FILE_NAME\fP, \fB\-\-file FILE_NAME\fP
134
131
  Indicates that the private key will be saved to a specified file name.
@@ -312,6 +309,6 @@ $ knife user show "Dennis Teck" \-F json
312
309
  .sp
313
310
  Other formats available include \fBtext\fP, \fByaml\fP, and \fBpp\fP.
314
311
  .SH AUTHOR
315
- Opscode
312
+ Chef
316
313
  .\" Generated by docutils manpage writer.
317
314
  .
@@ -33,66 +33,6 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
33
33
  .sp
34
34
  The \fBknife xargs\fP subcommand is used to build and execute command lines against objects on a server using standard input.
35
35
  .sp
36
- \fBCommon Options\fP
37
- .sp
38
- The following options can be run with all Knife sub\-commands and plug\-ins:
39
- .INDENT 0.0
40
- .TP
41
- .B \fB\-c CONFIG\fP, \fB\-\-config CONFIG\fP
42
- The configuration file to use.
43
- .TP
44
- .B \fB\-\-color\fP
45
- Indicates that colored output will be used.
46
- .TP
47
- .B \fB\-d\fP, \fB\-\-disable\-editing\fP
48
- Indicates that $EDITOR will not be opened; data will be accepted as\-is.
49
- .TP
50
- .B \fB\-\-defaults\fP
51
- Indicates that Knife will use the default value, instead of asking a user to provide one.
52
- .TP
53
- .B \fB\-e EDITOR\fP, \fB\-\-editor EDITOR\fP
54
- The $EDITOR that is used for all interactive commands.
55
- .TP
56
- .B \fB\-E ENVIRONMENT\fP, \fB\-\-environment ENVIRONMENT\fP
57
- The name of the environment. When this option is added to a command, the command will run only against the named environment.
58
- .TP
59
- .B \fB\-f FILE_NAME\fP, \fB\-\-file FILE_NAME\fP
60
- Indicates that the private key will be saved to a specified file name.
61
- .TP
62
- .B \fB\-F FORMAT\fP, \fB\-\-format FORMAT\fP
63
- The output format: \fBsummary\fP (default), \fBtext\fP, \fBjson\fP, \fByaml\fP, and \fBpp\fP.
64
- .TP
65
- .B \fB\-h\fP, \fB\-\-help\fP
66
- Shows help for the command.
67
- .TP
68
- .B \fB\-k KEY\fP, \fB\-\-key KEY\fP
69
- The private key that Knife will use to sign requests made by the API client to the server.
70
- .TP
71
- .B \fB\-\-no\-color\fP
72
- Indicates that color will not be used in the output.
73
- .TP
74
- .B \fB\-p PASSWORD\fP, \fB\-\-password PASSWORD\fP
75
- The user password.
76
- .TP
77
- .B \fB\-\-print\-after\fP
78
- Indicates that data will be shown after a destructive operation.
79
- .TP
80
- .B \fB\-s URL\fP, \fB\-\-server\-url URL\fP
81
- The URL for the server.
82
- .TP
83
- .B \fB\-u USER\fP, \fB\-\-user USER\fP
84
- The user name used by Knife to sign requests made by the API client to the server. Authentication will fail if the user name does not match the private key.
85
- .TP
86
- .B \fB\-v\fP, \fB\-\-version\fP
87
- The version of the chef\-client.
88
- .TP
89
- .B \fB\-V\fP, \fB\-\-verbose\fP
90
- Set for more verbose outputs. Use \fB\-VV\fP for maximum verbosity.
91
- .TP
92
- .B \fB\-y\fP, \fB\-\-yes\fP
93
- Indicates that the response to all confirmation prompts will be "Yes" (and that Knife will not ask for confirmation).
94
- .UNINDENT
95
- .sp
96
36
  \fBSyntax\fP
97
37
  .sp
98
38
  This argument has the following syntax:
@@ -111,44 +51,95 @@ This subcommand has the following options:
111
51
  .B \fB\-0\fP
112
52
  Indicates that a \fBNULL\fP character (\fB\e0\fP) will be used as a separator, instead of white space. Default: \fBfalse\fP.
113
53
  .TP
54
+ .B \fB\-c CONFIG_FILE\fP, \fB\-\-config CONFIG_FILE\fP
55
+ The configuration file to use.
56
+ .TP
114
57
  .B \fB\-\-chef\-repo\-path PATH\fP
115
58
  The path to the chef\-repo. This setting will override the default path to the chef\-repo. Default: same as specified by \fBchef_repo_path\fP in config.rb.
116
59
  .TP
60
+ .B \fB\-\-chef\-zero\-port PORT\fP
61
+ The port on which chef\-zero will listen.
62
+ .TP
63
+ .B \fB\-\-[no\-]color\fP
64
+ Indicates whether colored output will be used.
65
+ .TP
117
66
  .B \fB\-\-concurrency\fP
118
67
  The number of allowed concurrent connections. Default: \fB10\fP.
119
68
  .TP
69
+ .B \fB\-d\fP, \fB\-\-disable\-editing\fP
70
+ Indicates that $EDITOR will not be opened; data will be accepted as\-is.
71
+ .TP
72
+ .B \fB\-\-defaults\fP
73
+ Indicates that Knife will use the default value, instead of asking a user to provide one.
74
+ .TP
120
75
  .B \fB\-\-[no\-]diff\fP
121
76
  Use to show a diff when a file changes. Default: \fB\-\-diff\fP.
122
77
  .TP
123
78
  .B \fB\-\-dry\-run\fP
124
79
  Use to prevent changes from being uploaded to the server. Default: \fBfalse\fP.
125
80
  .TP
81
+ .B \fB\-e EDITOR\fP, \fB\-\-editor EDITOR\fP
82
+ The $EDITOR that is used for all interactive commands.
83
+ .TP
84
+ .B \fB\-E ENVIRONMENT\fP, \fB\-\-environment ENVIRONMENT\fP
85
+ The name of the environment. When this option is added to a command, the command will run only against the named environment.
86
+ .TP
87
+ .B \fB\-F FORMAT\fP, \fB\-\-format FORMAT\fP
88
+ The output format: \fBsummary\fP (default), \fBtext\fP, \fBjson\fP, \fByaml\fP, and \fBpp\fP.
89
+ .TP
126
90
  .B \fB\-\-[no\-]force\fP
127
91
  Use to force the upload of files even if they haven\(aqt been changed. Default: \fB\-\-no\-force\fP.
128
92
  .TP
93
+ .B \fB\-h\fP, \fB\-\-help\fP
94
+ Shows help for the command.
95
+ .TP
96
+ .B \fB\-I REPLACE_STRING\fP, \fB\-\-replace REPLACE_STRING\fP
97
+ Use to define a string that will be used to replace all occurrences of a file name. Default: \fBnil\fP.
98
+ .TP
99
+ .B \fB\-J REPLACE_STRING\fP, \fB\-\-replace\-first REPLACE_STRING\fP
100
+ Use to define a string that will be used to replace the first occurrence of a file name. Default: \fBnil\fP.
101
+ .TP
102
+ .B \fB\-k KEY\fP, \fB\-\-key KEY\fP
103
+ The private key that Knife will use to sign requests made by the API client to the server.
104
+ .TP
129
105
  .B \fB\-\-local\fP
130
106
  Indicates that a command line will be built or executed against a local file. Set to \fBfalse\fP to build or execute against a remote file. Default: \fBfalse\fP.
131
107
  .TP
132
108
  .B \fB\-n MAX_ARGS\fP, \fB\-\-max\-args MAX_ARGS\fP
133
109
  The maximum number of arguments per command line. Default: \fBnil\fP.
134
110
  .TP
135
- .B \fB\-s LENGTH\fP, \fB\-\-max\-chars LENGTH\fP
136
- The maximum size (in characters) for a command line. Default: \fBnil\fP.
137
- .TP
138
111
  .B \fB\-p [PATTERN...]\fP, \fB\-\-pattern [PATTERN...]\fP
139
112
  One (or more) patterns for a command line. If this option is not specified, a list of patterns may be expected on standard input. Default: \fBnil\fP.
140
113
  .TP
141
- .B \fB\-I REPLACE_STRING\fP, \fB\-\-replace REPLACE_STRING\fP
142
- Use to define a string that will be used to replace all occurrences of a file name. Default: \fBnil\fP.
143
- .TP
144
- .B \fB\-J REPLACE_STRING\fP, \fB\-\-replace\-first REPLACE_STRING\fP
145
- Use to define a string that will be used to replace the first occurrence of a file name. Default: \fBnil\fP.
114
+ .B \fB\-\-print\-after\fP
115
+ Indicates that data will be shown after a destructive operation.
146
116
  .TP
147
117
  .B \fB\-\-repo\-mode MODE\fP
148
118
  The layout of the local chef\-repo. Possible values: \fBstatic\fP, \fBeverything\fP, or \fBhosted_everything\fP. Use \fBstatic\fP for just roles, environments, cookbooks, and data bags. By default, \fBeverything\fP and \fBhosted_everything\fP are dynamically selected depending on the server type. Default value: \fBdefault\fP.
149
119
  .TP
120
+ .B \fB\-s LENGTH\fP, \fB\-\-max\-chars LENGTH\fP
121
+ The maximum size (in characters) for a command line. Default: \fBnil\fP.
122
+ .TP
123
+ .B \fB\-\-server\-url URL\fP
124
+ The URL for the server.
125
+ .TP
150
126
  .B \fB\-t\fP
151
127
  Indicates that the print command will be run on the command line. Default: \fBnil\fP.
128
+ .TP
129
+ .B \fB\-u USER\fP, \fB\-\-user USER\fP
130
+ The user name used by Knife to sign requests made by the API client to the server. Authentication will fail if the user name does not match the private key.
131
+ .TP
132
+ .B \fB\-v\fP, \fB\-\-version\fP
133
+ The version of the chef\-client.
134
+ .TP
135
+ .B \fB\-V\fP, \fB\-\-verbose\fP
136
+ Set for more verbose outputs. Use \fB\-VV\fP for maximum verbosity.
137
+ .TP
138
+ .B \fB\-y\fP, \fB\-\-yes\fP
139
+ Indicates that the response to all confirmation prompts will be "Yes" (and that Knife will not ask for confirmation).
140
+ .TP
141
+ .B \fB\-z\fP, \fB\-\-local\-mode\fP
142
+ Indicates that the chef\-client will be run in local mode, which allows all commands that work against the server to also work against the local chef\-repo.
152
143
  .UNINDENT
153
144
  .sp
154
145
  \fBExamples\fP
@@ -161,6 +152,6 @@ $ knife deps nodes/*.json | xargs knife upload
161
152
  .ft P
162
153
  .fi
163
154
  .SH AUTHOR
164
- Opscode
155
+ Chef
165
156
  .\" Generated by docutils manpage writer.
166
157
  .
@@ -118,11 +118,13 @@ class Chef::Application
118
118
  configure_stdout_logger
119
119
  end
120
120
  Chef::Log.level = resolve_log_level
121
+ rescue StandardError => error
122
+ Chef::Log.fatal("Failed to open or create log file at #{Chef::Config[:log_location]}: #{error.class} (#{error.message})")
123
+ Chef::Application.fatal!("Aborting due to invalid 'log_location' configuration", 2)
121
124
  end
122
125
 
123
126
  def configure_stdout_logger
124
127
  stdout_logger = MonoLogger.new(STDOUT)
125
- STDOUT.sync = true
126
128
  stdout_logger.formatter = Chef::Log.logger.formatter
127
129
  Chef::Log.loggers << stdout_logger
128
130
  end
@@ -233,7 +233,6 @@ class Chef
233
233
 
234
234
  def configure_stdout_logger
235
235
  stdout_logger = MonoLogger.new(STDOUT)
236
- STDOUT.sync = true
237
236
  stdout_logger.formatter = Chef::Log.logger.formatter
238
237
  Chef::Log.loggers << stdout_logger
239
238
  end
@@ -43,6 +43,7 @@ require 'chef/formatters/minimal'
43
43
  require 'chef/version'
44
44
  require 'chef/resource_reporter'
45
45
  require 'chef/run_lock'
46
+ require 'chef/policy_builder'
46
47
  require 'ohai'
47
48
  require 'rbconfig'
48
49
 
@@ -147,7 +148,6 @@ class Chef
147
148
  @events = EventDispatch::Dispatcher.new(*event_handlers)
148
149
  @override_runlist = args.delete(:override_runlist)
149
150
  @specific_recipes = args.delete(:specific_recipes)
150
- runlist_override_sanity_check!
151
151
  end
152
152
 
153
153
  def configure_formatters
@@ -226,38 +226,40 @@ class Chef
226
226
  raise Exceptions::ChildConvergeError, message
227
227
  end
228
228
 
229
+ # Instantiates a Chef::Node object, possibly loading the node's prior state
230
+ # when using chef-client. Delegates to policy_builder
231
+ #
232
+ #
233
+ # === Returns
234
+ # Chef::Node:: The node object for this chef run
235
+ def load_node
236
+ policy_builder.load_node
237
+ @node = policy_builder.node
238
+ end
229
239
 
240
+ # Mutates the `node` object to prepare it for the chef run. Delegates to
241
+ # policy_builder
242
+ #
243
+ # === Returns
244
+ # Chef::Node:: The updated node object
245
+ def build_node
246
+ policy_builder.build_node
247
+ @run_status = Chef::RunStatus.new(node, events)
248
+ node
249
+ end
230
250
 
231
- # Configures the Chef::Cookbook::FileVendor class to fetch file from the
232
- # server or disk as appropriate, creates the run context for this run, and
233
- # sanity checks the cookbook collection.
234
- #===Returns
235
- # Chef::RunContext:: the run context for this run.
236
251
  def setup_run_context
237
- if Chef::Config[:solo]
238
- Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, Chef::Config[:cookbook_path]) }
239
- cl = Chef::CookbookLoader.new(Chef::Config[:cookbook_path])
240
- cl.load_cookbooks
241
- cookbook_collection = Chef::CookbookCollection.new(cl)
242
- run_context = Chef::RunContext.new(node, cookbook_collection, @events)
243
- else
244
- Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::RemoteFileVendor.new(manifest, rest) }
245
- cookbook_hash = sync_cookbooks
246
- cookbook_collection = Chef::CookbookCollection.new(cookbook_hash)
247
- run_context = Chef::RunContext.new(node, cookbook_collection, @events)
248
- end
249
- run_status.run_context = run_context
250
-
251
- run_context.load(@run_list_expansion)
252
- if @specific_recipes
253
- @specific_recipes.each do |recipe_file|
254
- run_context.load_recipe_file(recipe_file)
255
- end
256
- end
252
+ run_context = policy_builder.setup_run_context(@specific_recipes)
257
253
  assert_cookbook_path_not_empty(run_context)
254
+ run_status.run_context = run_context
258
255
  run_context
259
256
  end
260
257
 
258
+ def policy_builder
259
+ @policy_builder ||= Chef::PolicyBuilder.strategy.new(node_name, ohai.data, json_attribs, @override_runlist, events)
260
+ end
261
+
262
+
261
263
  def save_updated_node
262
264
  unless Chef::Config[:solo]
263
265
  Chef::Log.debug("Saving the current state of node #{node_name}")
@@ -291,85 +293,6 @@ class Chef
291
293
  name
292
294
  end
293
295
 
294
- # Applies environment, external JSON attributes, and override run list to
295
- # the node, Then expands the run_list.
296
- #
297
- # === Returns
298
- # node<Chef::Node>:: The modified @node object. @node is modified in place.
299
- def build_node
300
- # Allow user to override the environment of a node by specifying
301
- # a config parameter.
302
- if Chef::Config[:environment] && !Chef::Config[:environment].chop.empty?
303
- @node.chef_environment(Chef::Config[:environment])
304
- end
305
-
306
- # consume_external_attrs may add items to the run_list. Save the
307
- # expanded run_list, which we will pass to the server later to
308
- # determine which versions of cookbooks to use.
309
- @node.reset_defaults_and_overrides
310
- @node.consume_external_attrs(ohai.data, @json_attribs)
311
-
312
- unless(@override_runlist.empty?)
313
- @original_runlist = @node.run_list.run_list_items.dup
314
- runlist_override_sanity_check!
315
- @node.run_list(*@override_runlist)
316
- Chef::Log.warn "Run List override has been provided."
317
- Chef::Log.warn "Original Run List: [#{@original_runlist.join(', ')}]"
318
- Chef::Log.warn "Overridden Run List: [#{@node.run_list}]"
319
- end
320
-
321
- @run_list_expansion = expand_run_list
322
-
323
- # @run_list_expansion is a RunListExpansion.
324
- #
325
- # Convert @expanded_run_list, which is an
326
- # Array of Hashes of the form
327
- # {:name => NAME, :version_constraint => Chef::VersionConstraint },
328
- # into @expanded_run_list_with_versions, an
329
- # Array of Strings of the form
330
- # "#{NAME}@#{VERSION}"
331
- @expanded_run_list_with_versions = @run_list_expansion.recipes.with_version_constraints_strings
332
-
333
- Chef::Log.info("Run List is [#{@node.run_list}]")
334
- Chef::Log.info("Run List expands to [#{@expanded_run_list_with_versions.join(', ')}]")
335
-
336
- @run_status = Chef::RunStatus.new(@node, @events)
337
-
338
- @events.node_load_completed(node, @expanded_run_list_with_versions, Chef::Config)
339
-
340
- @node
341
- end
342
-
343
- # In client-server operation, loads the node state from the server. In
344
- # chef-solo operation, builds a new node object.
345
- def load_node
346
- @events.node_load_start(node_name, Chef::Config)
347
- Chef::Log.debug("Building node object for #{node_name}")
348
-
349
- if Chef::Config[:solo]
350
- @node = Chef::Node.build(node_name)
351
- else
352
- @node = Chef::Node.find_or_create(node_name)
353
- end
354
- rescue Exception => e
355
- # TODO: wrap this exception so useful error info can be given to the
356
- # user.
357
- @events.node_load_failed(node_name, e, Chef::Config)
358
- raise
359
- end
360
-
361
- def expand_run_list
362
- if Chef::Config[:solo]
363
- @node.expand!('disk')
364
- else
365
- @node.expand!('server')
366
- end
367
- rescue Exception => e
368
- # TODO: wrap/munge exception with useful error output.
369
- @events.run_list_expand_failed(node, e)
370
- raise
371
- end
372
-
373
296
  #
374
297
  # === Returns
375
298
  # rest<Chef::REST>:: returns Chef::REST connection object
@@ -397,37 +320,6 @@ class Chef
397
320
  raise
398
321
  end
399
322
 
400
- # Sync_cookbooks eagerly loads all files except files and
401
- # templates. It returns the cookbook_hash -- the return result
402
- # from /environments/#{node.chef_environment}/cookbook_versions,
403
- # which we will use for our run_context.
404
- #
405
- # === Returns
406
- # Hash:: The hash of cookbooks with download URLs as given by the server
407
- def sync_cookbooks
408
- Chef::Log.debug("Synchronizing cookbooks")
409
-
410
- begin
411
- @events.cookbook_resolution_start(@expanded_run_list_with_versions)
412
- cookbook_hash = rest.post_rest("environments/#{@node.chef_environment}/cookbook_versions",
413
- {:run_list => @expanded_run_list_with_versions})
414
- rescue Exception => e
415
- # TODO: wrap/munge exception to provide helpful error output
416
- @events.cookbook_resolution_failed(@expanded_run_list_with_versions, e)
417
- raise
418
- else
419
- @events.cookbook_resolution_complete(cookbook_hash)
420
- end
421
-
422
- synchronizer = Chef::CookbookSynchronizer.new(cookbook_hash, @events)
423
- synchronizer.sync_cookbooks
424
-
425
- # register the file cache path in the cookbook path so that CookbookLoader actually picks up the synced cookbooks
426
- Chef::Config[:cookbook_path] = File.join(Chef::Config[:file_cache_path], "cookbooks")
427
-
428
- cookbook_hash
429
- end
430
-
431
323
  # Converges the node.
432
324
  #
433
325
  # === Returns
@@ -445,6 +337,19 @@ class Chef
445
337
  raise
446
338
  end
447
339
 
340
+ # Expands the run list. Delegates to the policy_builder.
341
+ #
342
+ # Normally this does not need to be called from here, it will be called by
343
+ # build_node. This is provided so external users (like the chefspec
344
+ # project) can inject custom behavior into the run process.
345
+ #
346
+ # === Returns
347
+ # RunListExpansion: A RunListExpansion or API compatible object.
348
+ def expanded_run_list
349
+ policy_builder.expand_run_list
350
+ end
351
+
352
+
448
353
  def do_windows_admin_check
449
354
  if Chef::Platform.windows?
450
355
  Chef::Log.debug("Checking for administrator privileges....")
@@ -533,22 +438,6 @@ class Chef
533
438
  true
534
439
  end
535
440
 
536
- # Ensures runlist override contains RunListItem instances
537
- def runlist_override_sanity_check!
538
- # Convert to array and remove whitespace
539
- if @override_runlist.is_a?(String)
540
- @override_runlist = @override_runlist.split(',').map { |e| e.strip }
541
- end
542
- @override_runlist = [@override_runlist].flatten.compact
543
- @override_runlist.map! do |item|
544
- if(item.is_a?(Chef::RunList::RunListItem))
545
- item
546
- else
547
- Chef::RunList::RunListItem.new(item)
548
- end
549
- end
550
- end
551
-
552
441
  def empty_directory?(path)
553
442
  !File.exists?(path) || (Dir.entries(path).size <= 2)
554
443
  end