chef 13.11.3 → 13.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -3
- data/README.md +35 -40
- data/Rakefile +18 -22
- data/chef-universal-mingw32.gemspec +1 -1
- data/chef.gemspec +3 -3
- data/lib/chef/client.rb +1 -1
- data/lib/chef/mixin/params_validate.rb +3 -1
- data/lib/chef/provider/script.rb +2 -2
- data/lib/chef/version.rb +1 -1
- data/spec/functional/http/simple_spec.rb +12 -6
- data/spec/functional/resource/remote_file_spec.rb +19 -15
- data/spec/support/platform_helpers.rb +2 -1
- data/tasks/announce.rb +1 -1
- data/tasks/dependencies.rb +5 -39
- data/tasks/maintainers.rb +10 -10
- data/tasks/rspec.rb +2 -2
- data/tasks/templates/prerelease.md.erb +11 -2
- data/tasks/templates/release.md.erb +9 -1
- metadata +6 -248
- data/CONTRIBUTING.md +0 -151
- data/VERSION +0 -1
- data/acceptance/.gitignore +0 -3
- data/acceptance/.shared/kitchen_acceptance/.kitchen.digitalocean.yml +0 -33
- data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +0 -283
- data/acceptance/.shared/kitchen_acceptance/.kitchen.vagrant.yml +0 -59
- data/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb +0 -68
- data/acceptance/.shared/kitchen_acceptance/metadata.rb +0 -1
- data/acceptance/Gemfile +0 -19
- data/acceptance/Gemfile.lock +0 -266
- data/acceptance/README.md +0 -137
- data/acceptance/basics/.acceptance/acceptance-cookbook/.gitignore +0 -2
- data/acceptance/basics/.acceptance/acceptance-cookbook/metadata.rb +0 -3
- data/acceptance/basics/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -1
- data/acceptance/basics/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -1
- data/acceptance/basics/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -1
- data/acceptance/basics/.kitchen.yml +0 -4
- data/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb +0 -19
- data/acceptance/basics/test/integration/chef-current-install/serverspec/spec_helper.rb +0 -6
- data/acceptance/basics/test/integration/helpers/serverspec/Gemfile +0 -8
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/.gitignore +0 -2
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/metadata.rb +0 -3
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -2
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -2
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -2
- data/acceptance/data-collector/.acceptance/data-collector-test/.gitignore +0 -16
- data/acceptance/data-collector/.acceptance/data-collector-test/Berksfile +0 -3
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb +0 -101
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/apigemfile +0 -3
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-both-mode.rb +0 -4
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-client-mode.rb +0 -4
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-no-endpoint.rb +0 -2
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-solo-mode.rb +0 -4
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/config.ru +0 -2
- data/acceptance/data-collector/.acceptance/data-collector-test/metadata.rb +0 -7
- data/acceptance/data-collector/.acceptance/data-collector-test/recipes/default.rb +0 -44
- data/acceptance/data-collector/.kitchen.yml +0 -9
- data/acceptance/data-collector/Berksfile +0 -3
- data/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb +0 -208
- data/acceptance/data-collector/test/integration/helpers/serverspec/Gemfile +0 -8
- data/acceptance/omnitruck/.acceptance/acceptance-cookbook/.gitignore +0 -2
- data/acceptance/omnitruck/.acceptance/acceptance-cookbook/metadata.rb +0 -1
- data/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -1
- data/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -1
- data/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -61
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/.gitignore +0 -2
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb +0 -43
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +0 -41
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/metadata.rb +0 -3
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -1
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -1
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -1
- data/acceptance/top-cookbooks/.gitignore +0 -1
- data/acceptance/top-cookbooks/.kitchen.chocolatey.yml +0 -6
- data/acceptance/top-cookbooks/.kitchen.iis.yml +0 -4
- data/acceptance/top-cookbooks/.kitchen.learn-the-basics-rhel.yml +0 -7
- data/acceptance/top-cookbooks/.kitchen.learn-the-basics-ubuntu.yml +0 -7
- data/acceptance/top-cookbooks/.kitchen.learn-the-basics-windows.yml +0 -7
- data/acceptance/top-cookbooks/.kitchen.powershell.yml +0 -4
- data/acceptance/top-cookbooks/.kitchen.sql_server.yml +0 -5
- data/acceptance/top-cookbooks/.kitchen.winbox.yml +0 -8
- data/acceptance/top-cookbooks/.kitchen.windows.yml +0 -38
- data/acceptance/trivial/.acceptance/acceptance-cookbook/.gitignore +0 -2
- data/acceptance/trivial/.acceptance/acceptance-cookbook/metadata.rb +0 -2
- data/acceptance/trivial/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -1
- data/acceptance/trivial/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -1
- data/acceptance/trivial/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -1
- data/acceptance/trivial/.kitchen.yml +0 -7
- data/acceptance/trivial/test/integration/chef-current-install/inspec/chef_client_spec.rb +0 -5
- data/acceptance/windows-service/.acceptance/acceptance-cookbook/.gitignore +0 -2
- data/acceptance/windows-service/.acceptance/acceptance-cookbook/metadata.rb +0 -2
- data/acceptance/windows-service/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -1
- data/acceptance/windows-service/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -1
- data/acceptance/windows-service/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -1
- data/acceptance/windows-service/.kitchen.yml +0 -7
- data/acceptance/windows-service/test/integration/chef-windows-service/inspec/chef_windows_service_spec.rb +0 -58
- data/distro/common/html/_sources/ctl_chef_client.txt +0 -36
- data/distro/common/html/_sources/ctl_chef_server.txt +0 -341
- data/distro/common/html/_sources/ctl_chef_shell.txt +0 -15
- data/distro/common/html/_sources/ctl_chef_solo.txt +0 -25
- data/distro/common/html/_sources/index.txt +0 -135
- data/distro/common/html/_sources/knife.txt +0 -74
- data/distro/common/html/_sources/knife_bootstrap.txt +0 -56
- data/distro/common/html/_sources/knife_client.txt +0 -151
- data/distro/common/html/_sources/knife_common_options.txt +0 -6
- data/distro/common/html/_sources/knife_configure.txt +0 -29
- data/distro/common/html/_sources/knife_cookbook.txt +0 -236
- data/distro/common/html/_sources/knife_cookbook_site.txt +0 -157
- data/distro/common/html/_sources/knife_data_bag.txt +0 -160
- data/distro/common/html/_sources/knife_delete.txt +0 -26
- data/distro/common/html/_sources/knife_deps.txt +0 -61
- data/distro/common/html/_sources/knife_diff.txt +0 -34
- data/distro/common/html/_sources/knife_download.txt +0 -44
- data/distro/common/html/_sources/knife_edit.txt +0 -26
- data/distro/common/html/_sources/knife_environment.txt +0 -158
- data/distro/common/html/_sources/knife_exec.txt +0 -47
- data/distro/common/html/_sources/knife_index_rebuild.txt +0 -21
- data/distro/common/html/_sources/knife_list.txt +0 -33
- data/distro/common/html/_sources/knife_node.txt +0 -250
- data/distro/common/html/_sources/knife_raw.txt +0 -35
- data/distro/common/html/_sources/knife_recipe_list.txt +0 -23
- data/distro/common/html/_sources/knife_role.txt +0 -157
- data/distro/common/html/_sources/knife_search.txt +0 -53
- data/distro/common/html/_sources/knife_serve.txt +0 -19
- data/distro/common/html/_sources/knife_show.txt +0 -27
- data/distro/common/html/_sources/knife_ssh.txt +0 -43
- data/distro/common/html/_sources/knife_ssl_check.txt +0 -41
- data/distro/common/html/_sources/knife_ssl_fetch.txt +0 -41
- data/distro/common/html/_sources/knife_status.txt +0 -37
- data/distro/common/html/_sources/knife_tag.txt +0 -69
- data/distro/common/html/_sources/knife_upload.txt +0 -49
- data/distro/common/html/_sources/knife_user.txt +0 -127
- data/distro/common/html/_sources/knife_using.txt +0 -43
- data/distro/common/html/_sources/knife_xargs.txt +0 -30
- data/distro/common/html/_static/ajax-loader.gif +0 -0
- data/distro/common/html/_static/basic.css +0 -537
- data/distro/common/html/_static/chef.ico +0 -0
- data/distro/common/html/_static/chef_html_logo.png +0 -0
- data/distro/common/html/_static/comment-bright.png +0 -0
- data/distro/common/html/_static/comment-close.png +0 -0
- data/distro/common/html/_static/comment.png +0 -0
- data/distro/common/html/_static/contents.png +0 -0
- data/distro/common/html/_static/doctools.js +0 -238
- data/distro/common/html/_static/down-pressed.png +0 -0
- data/distro/common/html/_static/down.png +0 -0
- data/distro/common/html/_static/file.png +0 -0
- data/distro/common/html/_static/guide.css +0 -505
- data/distro/common/html/_static/jquery.js +0 -2
- data/distro/common/html/_static/minus.png +0 -0
- data/distro/common/html/_static/navigation.png +0 -0
- data/distro/common/html/_static/plus.png +0 -0
- data/distro/common/html/_static/pygments.css +0 -62
- data/distro/common/html/_static/searchtools.js +0 -622
- data/distro/common/html/_static/underscore.js +0 -31
- data/distro/common/html/_static/up-pressed.png +0 -0
- data/distro/common/html/_static/up.png +0 -0
- data/distro/common/html/_static/websupport.js +0 -808
- data/distro/common/html/ctl_chef_client.html +0 -270
- data/distro/common/html/ctl_chef_server.html +0 -728
- data/distro/common/html/ctl_chef_shell.html +0 -163
- data/distro/common/html/ctl_chef_solo.html +0 -194
- data/distro/common/html/index.html +0 -202
- data/distro/common/html/knife.html +0 -170
- data/distro/common/html/knife_bootstrap.html +0 -285
- data/distro/common/html/knife_client.html +0 -285
- data/distro/common/html/knife_common_options.html +0 -96
- data/distro/common/html/knife_configure.html +0 -105
- data/distro/common/html/knife_cookbook.html +0 -487
- data/distro/common/html/knife_cookbook_site.html +0 -375
- data/distro/common/html/knife_data_bag.html +0 -374
- data/distro/common/html/knife_delete.html +0 -93
- data/distro/common/html/knife_deps.html +0 -143
- data/distro/common/html/knife_diff.html +0 -123
- data/distro/common/html/knife_download.html +0 -145
- data/distro/common/html/knife_edit.html +0 -89
- data/distro/common/html/knife_environment.html +0 -322
- data/distro/common/html/knife_exec.html +0 -220
- data/distro/common/html/knife_index_rebuild.html +0 -83
- data/distro/common/html/knife_list.html +0 -114
- data/distro/common/html/knife_node.html +0 -458
- data/distro/common/html/knife_raw.html +0 -110
- data/distro/common/html/knife_recipe_list.html +0 -91
- data/distro/common/html/knife_role.html +0 -295
- data/distro/common/html/knife_search.html +0 -203
- data/distro/common/html/knife_serve.html +0 -79
- data/distro/common/html/knife_show.html +0 -104
- data/distro/common/html/knife_ssh.html +0 -177
- data/distro/common/html/knife_ssl_check.html +0 -151
- data/distro/common/html/knife_ssl_fetch.html +0 -151
- data/distro/common/html/knife_status.html +0 -144
- data/distro/common/html/knife_tag.html +0 -138
- data/distro/common/html/knife_upload.html +0 -153
- data/distro/common/html/knife_user.html +0 -242
- data/distro/common/html/knife_using.html +0 -210
- data/distro/common/html/knife_xargs.html +0 -122
- data/distro/common/html/objects.inv +0 -0
- data/distro/common/html/search.html +0 -82
- data/distro/common/html/searchindex.js +0 -1
- data/distro/common/man/man1/README.md +0 -58
- data/distro/common/man/man1/chef-shell.1 +0 -194
- data/distro/common/man/man1/knife-bootstrap.1 +0 -215
- data/distro/common/man/man1/knife-client.1 +0 -443
- data/distro/common/man/man1/knife-configure.1 +0 -161
- data/distro/common/man/man1/knife-cookbook-site.1 +0 -552
- data/distro/common/man/man1/knife-cookbook.1 +0 -770
- data/distro/common/man/man1/knife-data-bag.1 +0 -617
- data/distro/common/man/man1/knife-delete.1 +0 -127
- data/distro/common/man/man1/knife-deps.1 +0 -246
- data/distro/common/man/man1/knife-diff.1 +0 -226
- data/distro/common/man/man1/knife-download.1 +0 -258
- data/distro/common/man/man1/knife-edit.1 +0 -121
- data/distro/common/man/man1/knife-environment.1 +0 -496
- data/distro/common/man/man1/knife-exec.1 +0 -362
- data/distro/common/man/man1/knife-index-rebuild.1 +0 -63
- data/distro/common/man/man1/knife-list.1 +0 -174
- data/distro/common/man/man1/knife-node.1 +0 -716
- data/distro/common/man/man1/knife-raw.1 +0 -172
- data/distro/common/man/man1/knife-recipe-list.1 +0 -85
- data/distro/common/man/man1/knife-role.1 +0 -426
- data/distro/common/man/man1/knife-search.1 +0 -359
- data/distro/common/man/man1/knife-serve.1 +0 -109
- data/distro/common/man/man1/knife-show.1 +0 -160
- data/distro/common/man/man1/knife-ssh.1 +0 -284
- data/distro/common/man/man1/knife-ssl-check.1 +0 -207
- data/distro/common/man/man1/knife-ssl-fetch.1 +0 -207
- data/distro/common/man/man1/knife-status.1 +0 -234
- data/distro/common/man/man1/knife-tag.1 +0 -189
- data/distro/common/man/man1/knife-upload.1 +0 -280
- data/distro/common/man/man1/knife-user.1 +0 -356
- data/distro/common/man/man1/knife-xargs.1 +0 -189
- data/distro/common/man/man1/knife.1 +0 -332
- data/distro/common/man/man8/chef-apply.8 +0 -86
- data/distro/common/man/man8/chef-client.8 +0 -398
- data/distro/common/man/man8/chef-solo.8 +0 -260
- data/distro/common/markdown/README +0 -3
- data/distro/common/markdown/man1/chef-shell.mkd +0 -195
- data/distro/common/markdown/man1/knife-bootstrap.mkd +0 -141
- data/distro/common/markdown/man1/knife-client.mkd +0 -103
- data/distro/common/markdown/man1/knife-configure.mkd +0 -71
- data/distro/common/markdown/man1/knife-cookbook-site.mkd +0 -123
- data/distro/common/markdown/man1/knife-cookbook.mkd +0 -263
- data/distro/common/markdown/man1/knife-data-bag.mkd +0 -121
- data/distro/common/markdown/man1/knife-environment.mkd +0 -151
- data/distro/common/markdown/man1/knife-exec.mkd +0 -42
- data/distro/common/markdown/man1/knife-index.mkd +0 -30
- data/distro/common/markdown/man1/knife-node.mkd +0 -130
- data/distro/common/markdown/man1/knife-role.mkd +0 -85
- data/distro/common/markdown/man1/knife-search.mkd +0 -180
- data/distro/common/markdown/man1/knife-ssh.mkd +0 -69
- data/distro/common/markdown/man1/knife-status.mkd +0 -36
- data/distro/common/markdown/man1/knife-tag.mkd +0 -39
- data/distro/common/markdown/man1/knife.mkd +0 -213
- data/distro/common/markdown/man8/chef-client.mkd +0 -75
- data/distro/common/markdown/man8/chef-expander.mkd +0 -81
- data/distro/common/markdown/man8/chef-expanderctl.mkd +0 -57
- data/distro/common/markdown/man8/chef-server-webui.mkd +0 -121
- data/distro/common/markdown/man8/chef-server.mkd +0 -120
- data/distro/common/markdown/man8/chef-solo.mkd +0 -107
- data/distro/common/markdown/man8/chef-solr.mkd +0 -89
- data/distro/powershell/chef/chef.psm1 +0 -459
- data/tasks/cbgb.rb +0 -84
@@ -1,107 +0,0 @@
|
|
1
|
-
chef-solo(8) -- Runs chef in solo mode against a specified cookbook location.
|
2
|
-
========================================
|
3
|
-
|
4
|
-
## SYNOPSIS
|
5
|
-
|
6
|
-
__chef-solo__ _(options)_
|
7
|
-
|
8
|
-
* `-c`, `--config CONFIG`:
|
9
|
-
The configuration file to use
|
10
|
-
* `-d`, `--daemonize`:
|
11
|
-
Daemonize the process
|
12
|
-
* `-g`, `--group GROUP`:
|
13
|
-
Group to set privilege to
|
14
|
-
* `-i`, `--interval SECONDS`:
|
15
|
-
Run chef-client periodically, in seconds
|
16
|
-
* `-j`, `--json-attributes JSON_ATTRIBS`:
|
17
|
-
Load attributes from a JSON file or URL
|
18
|
-
* `-l`, `--log_level LEVEL`:
|
19
|
-
Set the log level (debug, info, warn, error, fatal)
|
20
|
-
* `-L`, `--logfile LOGLOCATION`:
|
21
|
-
Set the log file location, defaults to STDOUT - recommended for
|
22
|
-
daemonizing
|
23
|
-
* `-N`, `--node-name NODE_NAME`:
|
24
|
-
The node name for this client
|
25
|
-
* `-r`, `--recipe-url RECIPE_URL`:
|
26
|
-
Pull down a remote gzipped tarball of recipes and untar it to the
|
27
|
-
cookbook cache.
|
28
|
-
* `-s`, `--splay SECONDS`:
|
29
|
-
The splay time for running at intervals, in seconds
|
30
|
-
* `-u`, `--user USER`:
|
31
|
-
User to set privilege to
|
32
|
-
* `-v`, `--version`:
|
33
|
-
Show chef version
|
34
|
-
* `-h`, `--help`:
|
35
|
-
Show this message
|
36
|
-
|
37
|
-
## DESCRIPTION
|
38
|
-
|
39
|
-
Chef Solo allows you to run Chef Cookbooks in the absence of a Chef Server.
|
40
|
-
To do this, the complete cookbook needs to be present on disk.
|
41
|
-
|
42
|
-
By default Chef Solo will look in /etc/chef/solo.rb for its configuration.
|
43
|
-
This configuration file has two required variables: file_cache_path and
|
44
|
-
cookbook_path.
|
45
|
-
|
46
|
-
For example:
|
47
|
-
file_cache_path "/var/chef-solo"
|
48
|
-
cookbook_path "/var/chef-solo/cookbooks"
|
49
|
-
|
50
|
-
For your own systems, you can change this to reflect any directory you like,
|
51
|
-
but you'll need to specify absolute paths and the cookbook_path directory
|
52
|
-
should be a subdirectory of the file_cache_path.
|
53
|
-
|
54
|
-
You can also specify cookbook_path as an array, passing multiple locations
|
55
|
-
to search for cookbooks.
|
56
|
-
|
57
|
-
For example:
|
58
|
-
file_cache_path "/var/chef-solo"
|
59
|
-
cookbook_path ["/var/chef-solo/cookbooks", "/var/chef-solo/site-cookbooks"]
|
60
|
-
|
61
|
-
Note that earlier entries are now overridden by later ones.
|
62
|
-
|
63
|
-
Since chef-solo doesn't have any interaction with a Chef Server, you'll need
|
64
|
-
to specify node-specifc attributes in a JSON file. This can be located on the
|
65
|
-
target system itself, or it can be stored on a remote server such as S3, or a
|
66
|
-
web server on your network.
|
67
|
-
|
68
|
-
Within the JSON file, you'll also specify the recipes that Chef should run in
|
69
|
-
the "run_list". An example JSON file, which sets a resolv.conf:
|
70
|
-
|
71
|
-
{
|
72
|
-
"resolver": {
|
73
|
-
"nameservers": [ "10.0.0.1" ],
|
74
|
-
"search":"int.example.com"
|
75
|
-
},
|
76
|
-
"run_list": [ "recipe[resolver]" ]
|
77
|
-
}
|
78
|
-
|
79
|
-
Then you can run chef-solo with -j to specify the JSON file. It will look for
|
80
|
-
cookbooks in the cookbook_path configured in the configuration file, and apply
|
81
|
-
attributes and use the run_list from the JSON file specified.
|
82
|
-
|
83
|
-
You can use -c to specify the path to the configuration file (if you don't want
|
84
|
-
chef-solo to use the default). You can also specify -r for a cookbook tarball.
|
85
|
-
|
86
|
-
For example:
|
87
|
-
chef-solo -c ~/solo.rb -j ~/node.json -r http://www.example.com/chef-solo.tar.gz
|
88
|
-
|
89
|
-
In the above case, chef-solo would extract the tarball to your specified
|
90
|
-
cookbook_path, use ~/solo.rb as the configuration file, and apply attributes
|
91
|
-
and use the run_list from ~/node.json.
|
92
|
-
|
93
|
-
## SEE ALSO
|
94
|
-
|
95
|
-
Full documentation for Chef and chef-solo is located on the Chef docs site,
|
96
|
-
http://docs.chef.io/.
|
97
|
-
|
98
|
-
## AUTHOR
|
99
|
-
|
100
|
-
Chef was written by Adam Jacob <adam@ospcode.com> of Opscode
|
101
|
-
(http://www.opscode.com), with contributions from the community. This
|
102
|
-
manual page was written by Joshua Timberman <joshua@opscode.com> with
|
103
|
-
help2man. Permission is granted to copy, distribute and / or modify
|
104
|
-
this document under the terms of the Apache 2.0 License.
|
105
|
-
|
106
|
-
On Debian systems, the complete text of the Apache 2.0 License can be
|
107
|
-
found in /usr/share/common-licenses/Apache-2.0.
|
@@ -1,89 +0,0 @@
|
|
1
|
-
chef-solr(8) -- Runs as Chef's search server
|
2
|
-
========================================
|
3
|
-
|
4
|
-
## SYNOPSIS
|
5
|
-
|
6
|
-
__chef-solr__ _(options)_
|
7
|
-
|
8
|
-
* `-c`, `--config CONFIG`:
|
9
|
-
The configuration file to use
|
10
|
-
* `-d`, `--daemonize`:
|
11
|
-
Daemonize the process
|
12
|
-
* `-g`, `--group GROUP`:
|
13
|
-
Group to set privilege to
|
14
|
-
* `-l`, `--log_level LEVEL`:
|
15
|
-
Set the log level (debug, info, warn, error, fatal)
|
16
|
-
* `-L`, `--logfile LOGLOCATION`:
|
17
|
-
Set the log file location, defaults to STDOUT - recommended for daemonizing
|
18
|
-
* `-P`, `--pid PIDFILE`:
|
19
|
-
Set the PID file location, defaults to /tmp/chef-solr.pid
|
20
|
-
* `-D`, `--solr-data-dir PATH`:
|
21
|
-
Where the Solr data lives
|
22
|
-
* `-x`, `--solor-heap-size SIZE`:
|
23
|
-
Set the size of the Java Heap
|
24
|
-
* `-H`, `--solr-home-dir PATH`:
|
25
|
-
Solr home directory
|
26
|
-
* `-j`, `--java-opts OPTS`:
|
27
|
-
Raw options passed to Java
|
28
|
-
* `-x`, `--solor-heap-size`:
|
29
|
-
Set the size of the Java Heap
|
30
|
-
* `-W`, `--solr-jetty-dir PATH`:
|
31
|
-
Where to place the Solr Jetty instance
|
32
|
-
* `-u`, `--user USER`:
|
33
|
-
User to set privilege to
|
34
|
-
* `-v`, `--version`:
|
35
|
-
Show chef-solr version
|
36
|
-
* `-h`, `--help`:
|
37
|
-
Show this message
|
38
|
-
|
39
|
-
## DESCRIPTION
|
40
|
-
|
41
|
-
Chef-solr provides search service for Chef. You need to have both
|
42
|
-
chef-solr and chef-expander-cluster running in order for search to work.
|
43
|
-
|
44
|
-
__Installation__
|
45
|
-
|
46
|
-
Make sure you backed up your data if you are upgrading from a previous version.
|
47
|
-
Run chef-solr-installer to upgrade your Chef Solr installation. Answer "yes"
|
48
|
-
when prompted for confirmation. The process should look like this:
|
49
|
-
|
50
|
-
yourshell> chef-solr-installer
|
51
|
-
Configuration setting solr_heap_size is unknown and will be ignored
|
52
|
-
|
53
|
-
Chef Solr is already installed in /var/chef/solr
|
54
|
-
Do you want to overwrite the current install? All existing Solr data will be lost. [y/n] y
|
55
|
-
Removing the existing Chef Solr installation
|
56
|
-
rm -rf /var/chef/solr
|
57
|
-
rm -rf /var/chef/solr-jetty
|
58
|
-
rm -rf /var/chef/solr/data
|
59
|
-
Creating Solr Home Directory
|
60
|
-
mkdir -p /var/chef/solr
|
61
|
-
entering /var/chef/solr
|
62
|
-
tar zxvf /Users/ddeleo/opscode/chef/chef-solr/solr/solr-home.tar.gz
|
63
|
-
Creating Solr Data Directory
|
64
|
-
mkdir -p /var/chef/solr/data
|
65
|
-
Unpacking Solr Jetty
|
66
|
-
mkdir -p /var/chef/solr-jetty
|
67
|
-
entering /var/chef/solr-jetty
|
68
|
-
tar zxvf /Users/ddeleo/opscode/chef/chef-solr/solr/solr-jetty.tar.gz
|
69
|
-
|
70
|
-
Successfully installed Chef Solr.
|
71
|
-
You can restore your search index using `knife index rebuild`
|
72
|
-
|
73
|
-
## SEE ALSO
|
74
|
-
|
75
|
-
__chef-expander-cluster__(8)
|
76
|
-
|
77
|
-
Full documentation for Chef and chef-server is located on the Chef
|
78
|
-
Docs site, http://docs.chef.io/.
|
79
|
-
|
80
|
-
## AUTHOR
|
81
|
-
|
82
|
-
Chef was written by Adam Jacob <adam@ospcode.com> of Opscode
|
83
|
-
(http://www.opscode.com), with contributions from the community. This
|
84
|
-
manual page was written by Joshua Timberman <joshua@opscode.com> with
|
85
|
-
help2man. Permission is granted to copy, distribute and / or modify
|
86
|
-
this document under the terms of the Apache 2.0 License.
|
87
|
-
|
88
|
-
On Debian systems, the complete text of the Apache 2.0 License can be
|
89
|
-
found in /usr/share/common-licenses/Apache-2.0.
|
@@ -1,459 +0,0 @@
|
|
1
|
-
|
2
|
-
function Load-Win32Bindings {
|
3
|
-
Add-Type -TypeDefinition @"
|
4
|
-
using System;
|
5
|
-
using System.Diagnostics;
|
6
|
-
using System.Runtime.InteropServices;
|
7
|
-
|
8
|
-
namespace Chef
|
9
|
-
{
|
10
|
-
|
11
|
-
[StructLayout(LayoutKind.Sequential)]
|
12
|
-
public struct PROCESS_INFORMATION
|
13
|
-
{
|
14
|
-
public IntPtr hProcess;
|
15
|
-
public IntPtr hThread;
|
16
|
-
public uint dwProcessId;
|
17
|
-
public uint dwThreadId;
|
18
|
-
}
|
19
|
-
|
20
|
-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
21
|
-
public struct STARTUPINFO
|
22
|
-
{
|
23
|
-
public uint cb;
|
24
|
-
public string lpReserved;
|
25
|
-
public string lpDesktop;
|
26
|
-
public string lpTitle;
|
27
|
-
public uint dwX;
|
28
|
-
public uint dwY;
|
29
|
-
public uint dwXSize;
|
30
|
-
public uint dwYSize;
|
31
|
-
public uint dwXCountChars;
|
32
|
-
public uint dwYCountChars;
|
33
|
-
public uint dwFillAttribute;
|
34
|
-
public STARTF dwFlags;
|
35
|
-
public ShowWindow wShowWindow;
|
36
|
-
public short cbReserved2;
|
37
|
-
public IntPtr lpReserved2;
|
38
|
-
public IntPtr hStdInput;
|
39
|
-
public IntPtr hStdOutput;
|
40
|
-
public IntPtr hStdError;
|
41
|
-
}
|
42
|
-
|
43
|
-
[StructLayout(LayoutKind.Sequential)]
|
44
|
-
public struct SECURITY_ATTRIBUTES
|
45
|
-
{
|
46
|
-
public int length;
|
47
|
-
public IntPtr lpSecurityDescriptor;
|
48
|
-
public bool bInheritHandle;
|
49
|
-
}
|
50
|
-
|
51
|
-
[Flags]
|
52
|
-
public enum CreationFlags : int
|
53
|
-
{
|
54
|
-
NONE = 0,
|
55
|
-
DEBUG_PROCESS = 0x00000001,
|
56
|
-
DEBUG_ONLY_THIS_PROCESS = 0x00000002,
|
57
|
-
CREATE_SUSPENDED = 0x00000004,
|
58
|
-
DETACHED_PROCESS = 0x00000008,
|
59
|
-
CREATE_NEW_CONSOLE = 0x00000010,
|
60
|
-
CREATE_NEW_PROCESS_GROUP = 0x00000200,
|
61
|
-
CREATE_UNICODE_ENVIRONMENT = 0x00000400,
|
62
|
-
CREATE_SEPARATE_WOW_VDM = 0x00000800,
|
63
|
-
CREATE_SHARED_WOW_VDM = 0x00001000,
|
64
|
-
CREATE_PROTECTED_PROCESS = 0x00040000,
|
65
|
-
EXTENDED_STARTUPINFO_PRESENT = 0x00080000,
|
66
|
-
CREATE_BREAKAWAY_FROM_JOB = 0x01000000,
|
67
|
-
CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000,
|
68
|
-
CREATE_DEFAULT_ERROR_MODE = 0x04000000,
|
69
|
-
CREATE_NO_WINDOW = 0x08000000,
|
70
|
-
}
|
71
|
-
|
72
|
-
[Flags]
|
73
|
-
public enum STARTF : uint
|
74
|
-
{
|
75
|
-
STARTF_USESHOWWINDOW = 0x00000001,
|
76
|
-
STARTF_USESIZE = 0x00000002,
|
77
|
-
STARTF_USEPOSITION = 0x00000004,
|
78
|
-
STARTF_USECOUNTCHARS = 0x00000008,
|
79
|
-
STARTF_USEFILLATTRIBUTE = 0x00000010,
|
80
|
-
STARTF_RUNFULLSCREEN = 0x00000020, // ignored for non-x86 platforms
|
81
|
-
STARTF_FORCEONFEEDBACK = 0x00000040,
|
82
|
-
STARTF_FORCEOFFFEEDBACK = 0x00000080,
|
83
|
-
STARTF_USESTDHANDLES = 0x00000100,
|
84
|
-
}
|
85
|
-
|
86
|
-
public enum ShowWindow : short
|
87
|
-
{
|
88
|
-
SW_HIDE = 0,
|
89
|
-
SW_SHOWNORMAL = 1,
|
90
|
-
SW_NORMAL = 1,
|
91
|
-
SW_SHOWMINIMIZED = 2,
|
92
|
-
SW_SHOWMAXIMIZED = 3,
|
93
|
-
SW_MAXIMIZE = 3,
|
94
|
-
SW_SHOWNOACTIVATE = 4,
|
95
|
-
SW_SHOW = 5,
|
96
|
-
SW_MINIMIZE = 6,
|
97
|
-
SW_SHOWMINNOACTIVE = 7,
|
98
|
-
SW_SHOWNA = 8,
|
99
|
-
SW_RESTORE = 9,
|
100
|
-
SW_SHOWDEFAULT = 10,
|
101
|
-
SW_FORCEMINIMIZE = 11,
|
102
|
-
SW_MAX = 11
|
103
|
-
}
|
104
|
-
|
105
|
-
public enum StandardHandle : int
|
106
|
-
{
|
107
|
-
Input = -10,
|
108
|
-
Output = -11,
|
109
|
-
Error = -12
|
110
|
-
}
|
111
|
-
|
112
|
-
public enum HandleFlags : int
|
113
|
-
{
|
114
|
-
HANDLE_FLAG_INHERIT = 0x00000001,
|
115
|
-
HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002
|
116
|
-
}
|
117
|
-
|
118
|
-
public static class Kernel32
|
119
|
-
{
|
120
|
-
[DllImport("kernel32.dll", SetLastError=true)]
|
121
|
-
[return: MarshalAs(UnmanagedType.Bool)]
|
122
|
-
public static extern bool CreateProcess(
|
123
|
-
string lpApplicationName,
|
124
|
-
string lpCommandLine,
|
125
|
-
ref SECURITY_ATTRIBUTES lpProcessAttributes,
|
126
|
-
ref SECURITY_ATTRIBUTES lpThreadAttributes,
|
127
|
-
[MarshalAs(UnmanagedType.Bool)] bool bInheritHandles,
|
128
|
-
CreationFlags dwCreationFlags,
|
129
|
-
IntPtr lpEnvironment,
|
130
|
-
string lpCurrentDirectory,
|
131
|
-
ref STARTUPINFO lpStartupInfo,
|
132
|
-
out PROCESS_INFORMATION lpProcessInformation);
|
133
|
-
|
134
|
-
[DllImport("kernel32.dll", SetLastError=true)]
|
135
|
-
public static extern IntPtr GetStdHandle(
|
136
|
-
StandardHandle nStdHandle);
|
137
|
-
|
138
|
-
[DllImport("kernel32.dll")]
|
139
|
-
public static extern bool SetHandleInformation(
|
140
|
-
IntPtr hObject,
|
141
|
-
int dwMask,
|
142
|
-
uint dwFlags);
|
143
|
-
|
144
|
-
[DllImport("kernel32", SetLastError=true)]
|
145
|
-
[return: MarshalAs(UnmanagedType.Bool)]
|
146
|
-
public static extern bool CloseHandle(
|
147
|
-
IntPtr hObject);
|
148
|
-
|
149
|
-
[DllImport("kernel32", SetLastError=true)]
|
150
|
-
[return: MarshalAs(UnmanagedType.Bool)]
|
151
|
-
public static extern bool GetExitCodeProcess(
|
152
|
-
IntPtr hProcess,
|
153
|
-
out int lpExitCode);
|
154
|
-
|
155
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
156
|
-
public static extern bool CreatePipe(
|
157
|
-
out IntPtr phReadPipe,
|
158
|
-
out IntPtr phWritePipe,
|
159
|
-
IntPtr lpPipeAttributes,
|
160
|
-
uint nSize);
|
161
|
-
|
162
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
163
|
-
public static extern bool ReadFile(
|
164
|
-
IntPtr hFile,
|
165
|
-
[Out] byte[] lpBuffer,
|
166
|
-
uint nNumberOfBytesToRead,
|
167
|
-
ref int lpNumberOfBytesRead,
|
168
|
-
IntPtr lpOverlapped);
|
169
|
-
|
170
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
171
|
-
public static extern bool PeekNamedPipe(
|
172
|
-
IntPtr handle,
|
173
|
-
byte[] buffer,
|
174
|
-
uint nBufferSize,
|
175
|
-
ref uint bytesRead,
|
176
|
-
ref uint bytesAvail,
|
177
|
-
ref uint BytesLeftThisMessage);
|
178
|
-
|
179
|
-
public const int STILL_ACTIVE = 259;
|
180
|
-
}
|
181
|
-
}
|
182
|
-
"@
|
183
|
-
}
|
184
|
-
|
185
|
-
function Run-ExecutableAndWait($AppPath, $ArgumentString) {
|
186
|
-
# Use the Win32 API to create a new process and wait for it to terminate.
|
187
|
-
$null = Load-Win32Bindings
|
188
|
-
|
189
|
-
$si = New-Object Chef.STARTUPINFO
|
190
|
-
$pi = New-Object Chef.PROCESS_INFORMATION
|
191
|
-
|
192
|
-
$pSec = New-Object Chef.SECURITY_ATTRIBUTES
|
193
|
-
$pSec.Length = [System.Runtime.InteropServices.Marshal]::SizeOf($pSec)
|
194
|
-
$pSec.bInheritHandle = $true
|
195
|
-
$tSec = New-Object Chef.SECURITY_ATTRIBUTES
|
196
|
-
$tSec.Length = [System.Runtime.InteropServices.Marshal]::SizeOf($tSec)
|
197
|
-
$tSec.bInheritHandle = $true
|
198
|
-
|
199
|
-
# Create pipe for process stdout
|
200
|
-
$ptr = [System.Runtime.InteropServices.Marshal]::AllocHGlobal([System.Runtime.InteropServices.Marshal]::SizeOf($si))
|
201
|
-
[System.Runtime.InteropServices.Marshal]::StructureToPtr($pSec, $ptr, $true)
|
202
|
-
$hReadOut = [IntPtr]::Zero
|
203
|
-
$hWriteOut = [IntPtr]::Zero
|
204
|
-
$success = [Chef.Kernel32]::CreatePipe([ref] $hReadOut, [ref] $hWriteOut, $ptr, 0)
|
205
|
-
if (-Not $success) {
|
206
|
-
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
207
|
-
throw "Unable to create output pipe. Error code $reason."
|
208
|
-
}
|
209
|
-
$success = [Chef.Kernel32]::SetHandleInformation($hReadOut, [Chef.HandleFlags]::HANDLE_FLAG_INHERIT, 0)
|
210
|
-
if (-Not $success) {
|
211
|
-
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
212
|
-
throw "Unable to set output pipe handle information. Error code $reason."
|
213
|
-
}
|
214
|
-
|
215
|
-
$si.cb = [System.Runtime.InteropServices.Marshal]::SizeOf($si)
|
216
|
-
$si.wShowWindow = [Chef.ShowWindow]::SW_SHOW
|
217
|
-
$si.dwFlags = [Chef.STARTF]::STARTF_USESTDHANDLES
|
218
|
-
$si.hStdOutput = $hWriteOut
|
219
|
-
$si.hStdError = $hWriteOut
|
220
|
-
$si.hStdInput = [Chef.Kernel32]::GetStdHandle([Chef.StandardHandle]::Input)
|
221
|
-
|
222
|
-
$success = [Chef.Kernel32]::CreateProcess(
|
223
|
-
$AppPath,
|
224
|
-
$ArgumentString,
|
225
|
-
[ref] $pSec,
|
226
|
-
[ref] $tSec,
|
227
|
-
$true,
|
228
|
-
[Chef.CreationFlags]::NONE,
|
229
|
-
[IntPtr]::Zero,
|
230
|
-
$pwd,
|
231
|
-
[ref] $si,
|
232
|
-
[ref] $pi
|
233
|
-
)
|
234
|
-
if (-Not $success) {
|
235
|
-
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
236
|
-
throw "Unable to create process [$ArgumentString]. Error code $reason."
|
237
|
-
}
|
238
|
-
|
239
|
-
$buffer = New-Object byte[] 1024
|
240
|
-
|
241
|
-
# Initialize reference variables
|
242
|
-
$bytesRead = 0
|
243
|
-
$bytesAvailable = 0
|
244
|
-
$bytesLeftThisMsg = 0
|
245
|
-
$global:LASTEXITCODE = [Chef.Kernel32]::STILL_ACTIVE
|
246
|
-
|
247
|
-
$isActive = $true
|
248
|
-
while ($isActive) {
|
249
|
-
$success = [Chef.Kernel32]::GetExitCodeProcess($pi.hProcess, [ref] $global:LASTEXITCODE)
|
250
|
-
if (-Not $success) {
|
251
|
-
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
252
|
-
throw "Process exit code unavailable. Error code $reason."
|
253
|
-
}
|
254
|
-
|
255
|
-
$success = [Chef.Kernel32]::PeekNamedPipe(
|
256
|
-
$hReadOut,
|
257
|
-
$null,
|
258
|
-
$buffer.Length,
|
259
|
-
[ref] $bytesRead,
|
260
|
-
[ref] $bytesAvailable,
|
261
|
-
[ref] $bytesLeftThisMsg
|
262
|
-
)
|
263
|
-
if (-Not $success) {
|
264
|
-
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
265
|
-
throw "Output pipe unavailable for peeking. Error code $reason."
|
266
|
-
}
|
267
|
-
|
268
|
-
if ($bytesRead -gt 0) {
|
269
|
-
while ([Chef.Kernel32]::ReadFile($hReadOut, $buffer, $buffer.Length, [ref] $bytesRead, 0)) {
|
270
|
-
$output = [Text.Encoding]::UTF8.GetString($buffer, 0, $bytesRead)
|
271
|
-
if ($output) {
|
272
|
-
$output
|
273
|
-
}
|
274
|
-
if ($bytesRead -lt $buffer.Length) {
|
275
|
-
# Partial buffer indicating the end of stream, break out of ReadFile loop
|
276
|
-
# ReadFile will block until:
|
277
|
-
# The number of bytes requested is read.
|
278
|
-
# A write operation completes on the write end of the pipe.
|
279
|
-
# An asynchronous handle is being used and the read is occurring asynchronously.
|
280
|
-
# An error occurs.
|
281
|
-
break
|
282
|
-
}
|
283
|
-
}
|
284
|
-
} else {
|
285
|
-
# For some reason, you can't read from the read-end of the read-pipe before the write end has started
|
286
|
-
# to write. Otherwise the process just blocks forever and never returns from the read. So we peek
|
287
|
-
# at the pipe until there is something. But don't peek too eagerly. This is stupid stupid stupid.
|
288
|
-
# There must be a way to do this without having to peek at a pipe first but I have not found it.
|
289
|
-
#
|
290
|
-
# Note to the future intrepid soul who wants to fix this:
|
291
|
-
# 0) This is related to unreasonable CPU usage by the wrapper PS script on a 1 VCPU VM (either Hyper-V
|
292
|
-
# or VirtualBox) running a consumer Windows SKU (Windows 10 for example...). Test it there.
|
293
|
-
# 1) Maybe this entire script is unnecessary and the bugs mentioned below have been fixed or don't need
|
294
|
-
# to be supported.
|
295
|
-
# 2) The server and consumer windows schedulers have different defaults. I had a hard time reproducing
|
296
|
-
# any issue on a win 2008 on win 2012 server default setup. See the "foreground application scheduler
|
297
|
-
# priority" setting to see if it's relevant.
|
298
|
-
# 3) This entire endeavor is silly anyway - why are we reimplementing process forking all over? Maybe try
|
299
|
-
# to get the folks above to accept patches instead of extending this crazy script.
|
300
|
-
Start-Sleep -s 1
|
301
|
-
# Start-Sleep -m 100
|
302
|
-
}
|
303
|
-
|
304
|
-
if ($global:LASTEXITCODE -ne [Chef.Kernel32]::STILL_ACTIVE) {
|
305
|
-
$isActive = $false
|
306
|
-
}
|
307
|
-
}
|
308
|
-
|
309
|
-
# Cleanup handles
|
310
|
-
$success = [Chef.Kernel32]::CloseHandle($pi.hProcess)
|
311
|
-
if (-Not $success) {
|
312
|
-
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
313
|
-
throw "Unable to release process handle. Error code $reason."
|
314
|
-
}
|
315
|
-
$success = [Chef.Kernel32]::CloseHandle($pi.hThread)
|
316
|
-
if (-Not $success) {
|
317
|
-
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
318
|
-
throw "Unable to release thread handle. Error code $reason."
|
319
|
-
}
|
320
|
-
$success = [Chef.Kernel32]::CloseHandle($hWriteOut)
|
321
|
-
if (-Not $success) {
|
322
|
-
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
323
|
-
throw "Unable to release output write handle. Error code $reason."
|
324
|
-
}
|
325
|
-
$success = [Chef.Kernel32]::CloseHandle($hReadOut)
|
326
|
-
if (-Not $success) {
|
327
|
-
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
328
|
-
throw "Unable to release output read handle. Error code $reason."
|
329
|
-
}
|
330
|
-
[System.Runtime.InteropServices.Marshal]::FreeHGlobal($ptr)
|
331
|
-
}
|
332
|
-
|
333
|
-
function Get-ScriptDirectory {
|
334
|
-
if (!$PSScriptRoot) {
|
335
|
-
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
|
336
|
-
$PSScriptRoot = Split-Path $Invocation.MyCommand.Path
|
337
|
-
}
|
338
|
-
$PSScriptRoot
|
339
|
-
}
|
340
|
-
|
341
|
-
function Run-RubyCommand($command, $argList) {
|
342
|
-
# This method exists to take the given list of arguments and get it past ruby's command-line
|
343
|
-
# interpreter unscathed and untampered. See https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L1582
|
344
|
-
# for a list of transformations that ruby attempts to perform with your command-line arguments
|
345
|
-
# before passing it onto a script. The most important task is to defeat the globbing
|
346
|
-
# and wild-card expansion that ruby performs. Note that ruby does not use MSVCRT's argc/argv
|
347
|
-
# and deliberately reparses the raw command-line instead.
|
348
|
-
#
|
349
|
-
# To stop ruby from interpreting command-line arguments as globs, they need to be enclosed in '
|
350
|
-
# Ruby doesn't allow any escape characters inside '. This unfortunately prevents us from sending
|
351
|
-
# any strings which themselves contain '. Ruby does allow multi-fragment arguments though.
|
352
|
-
# "foo bar"'baz qux'123"foo" is interpreted as 1 argument because there are no un-escaped
|
353
|
-
# whitespace there. The argument would be interpreted as the string "foo barbaz qux123foo".
|
354
|
-
# This lets us escape ' characters by exiting the ' quoted string, injecting a "'" fragment and
|
355
|
-
# then resuming the ' quoted string again.
|
356
|
-
#
|
357
|
-
# In the process of defeating ruby, one must also defeat the helpfulness of powershell.
|
358
|
-
# When arguments come into this method, the standard PS rules for interpreting cmdlet arguments
|
359
|
-
# apply. When using & (call operator) and providing an array of arguments, powershell (verified
|
360
|
-
# on PS 4.0 on Windows Server 2012R2) will not evaluate them but (contrary to documentation),
|
361
|
-
# it will still marginally interpret them. The behaviour of PS 5.0 seems to be different but
|
362
|
-
# ignore that for now. If any of the provided arguments has a space in it, powershell checks
|
363
|
-
# the first and last character to ensure that they are " characters (and that's all it checks).
|
364
|
-
# If they are not, it will blindly surround that argument with " characters. It won't do this
|
365
|
-
# operation if no space is present, even if other special characters are present. If it notices
|
366
|
-
# leading and trailing " characters, it won't actually check to see if there are other "
|
367
|
-
# characters in the string. Since PS 5.0 changes this behavior, we could consider using the --%
|
368
|
-
# "stop screwing up my arguments" operator, which is available since PS 3.0. When encountered
|
369
|
-
# --% indicates that the rest of line is to be sent literally... except if the parser encounters
|
370
|
-
# %FOO% cmd style environment variables. Because reasons. And there is no way to escape the
|
371
|
-
# % character in *any* waym shape or form.
|
372
|
-
# https://connect.microsoft.com/PowerShell/feedback/details/376207/executing-commands-which-require-quotes-and-variables-is-practically-impossible
|
373
|
-
#
|
374
|
-
# In case you think that you're either reading this incorrectly or that I'm full of shit, here
|
375
|
-
# are some examples. These use EchoArgs.exe from the PowerShell Community Extensions package.
|
376
|
-
# I have not included the argument parsing output from EchoArgs.exe to prevent confusing you with
|
377
|
-
# more details about MSVCRT's parsing algorithm.
|
378
|
-
#
|
379
|
-
# $x = "foo '' bar `"baz`""
|
380
|
-
# & EchoArgs @($x, $x)
|
381
|
-
# Command line:
|
382
|
-
# "C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\Pscx\Apps\EchoArgs.exe" "foo '' bar "baz"" "foo '' bar "baz""
|
383
|
-
#
|
384
|
-
# $x = "abc'123'nospace`"lulz`"!!!"
|
385
|
-
# & EchoArgs @($x, $x)
|
386
|
-
# Command line:
|
387
|
-
# "C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\Pscx\Apps\EchoArgs.exe" abc'123'nospace"lulz"!!! abc'123'nospace"lulz"!!!
|
388
|
-
#
|
389
|
-
# $x = "`"`"Look ma! Tonnes of spaces! 'foo' 'bar'`"`""
|
390
|
-
# & EchoArgs @($x, $x)
|
391
|
-
# Command line:
|
392
|
-
# "C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\Pscx\Apps\EchoArgs.exe" ""Look ma! Tonnes of spaces! 'foo' 'bar'"" ""Look ma! Tonnes of spaces! 'foo' 'bar'""
|
393
|
-
#
|
394
|
-
# Given all this, we can now device a strategy to work around all these immensely helpful, well
|
395
|
-
# documented and useful tools by looking at each incoming argument, escaping any ' characters
|
396
|
-
# with a '"'"' sequence, surrounding each argument with ' & joining them with a space separating
|
397
|
-
# them.
|
398
|
-
# There is another bug (https://bugs.ruby-lang.org/issues/11142) that causes ruby to mangle any
|
399
|
-
# "" two-character double quote sequence but since we always emit our strings inside ' except for
|
400
|
-
# ' characters, this should be ok. Just remember that an argument '' should get translated to
|
401
|
-
# ''"'"''"'"'' on the command line. If those intervening empty ''s are not present, the presence
|
402
|
-
# of "" will cause ruby to mangle that argument.
|
403
|
-
$transformedList = $argList | foreach { "'" + ( $_ -replace "'","'`"'`"'" ) + "'" }
|
404
|
-
$fortifiedArgString = $transformedList -join ' '
|
405
|
-
|
406
|
-
# Use the correct embedded ruby path. We'll be deployed at a path that looks like
|
407
|
-
# [C:\opscode or some other prefix]\chef\modules\chef
|
408
|
-
$ruby = Join-Path (Get-ScriptDirectory) "..\..\embedded\bin\ruby.exe"
|
409
|
-
$commandPath = Join-Path (Get-ScriptDirectory) "..\..\bin\$command"
|
410
|
-
|
411
|
-
Run-ExecutableAndWait $ruby """$ruby"" '$commandPath' $fortifiedArgString"
|
412
|
-
}
|
413
|
-
|
414
|
-
|
415
|
-
function chef-apply {
|
416
|
-
Run-RubyCommand 'chef-apply' $args
|
417
|
-
}
|
418
|
-
|
419
|
-
function chef-client {
|
420
|
-
Run-RubyCommand 'chef-client' $args
|
421
|
-
}
|
422
|
-
|
423
|
-
function chef-service-manager {
|
424
|
-
Run-RubyCommand 'chef-service-manager' $args
|
425
|
-
}
|
426
|
-
|
427
|
-
function chef-shell {
|
428
|
-
Run-RubyCommand 'chef-shell' $args
|
429
|
-
}
|
430
|
-
|
431
|
-
function chef-solo {
|
432
|
-
Run-RubyCommand 'chef-solo' $args
|
433
|
-
}
|
434
|
-
|
435
|
-
function chef-windows-service {
|
436
|
-
Run-RubyCommand 'chef-windows-service' $args
|
437
|
-
}
|
438
|
-
|
439
|
-
function knife {
|
440
|
-
Run-RubyCommand 'knife' $args
|
441
|
-
}
|
442
|
-
|
443
|
-
Export-ModuleMember -function chef-apply
|
444
|
-
Export-ModuleMember -function chef-client
|
445
|
-
Export-ModuleMember -function chef-service-manager
|
446
|
-
Export-ModuleMember -function chef-shell
|
447
|
-
Export-ModuleMember -function chef-solo
|
448
|
-
Export-ModuleMember -function chef-windows-service
|
449
|
-
Export-ModuleMember -function knife
|
450
|
-
|
451
|
-
# To debug this module, uncomment the line below
|
452
|
-
# Export-ModuleMember -function Run-RubyCommand
|
453
|
-
|
454
|
-
# Then run the following to reload the module. Use puts_argv as a helpful debug executable.
|
455
|
-
# Remove-Module chef
|
456
|
-
# Import-Module chef
|
457
|
-
# "puts ARGV" | Out-File C:\opscode\chef\bin\puts_args -Encoding ASCII
|
458
|
-
# Copy-Item C:\opscode\chef\bin\ohai.bat C:\opscode\chef\bin\puts_args.bat
|
459
|
-
# Run-RubyCommand puts_args 'Here' "are" some '"very interesting"' 'arguments[to]' "`"try out`""
|