knife-solo 0.0.15 → 0.1.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +216 -0
- data/LICENSE +7 -0
- data/README.rdoc +127 -0
- data/Rakefile +31 -0
- data/lib/chef/knife/cook.rb +4 -131
- data/lib/chef/knife/kitchen.rb +4 -49
- data/lib/chef/knife/prepare.rb +4 -50
- data/lib/chef/knife/solo_bootstrap.rb +51 -0
- data/lib/chef/knife/solo_clean.rb +25 -0
- data/lib/chef/knife/solo_cook.rb +137 -0
- data/lib/chef/knife/solo_init.rb +59 -0
- data/lib/chef/knife/solo_prepare.rb +56 -0
- data/lib/chef/knife/wash_up.rb +4 -15
- data/lib/knife-solo/bootstraps.rb +1 -1
- data/lib/knife-solo/bootstraps/linux.rb +6 -4
- data/lib/knife-solo/bootstraps/sun_os.rb +9 -0
- data/lib/knife-solo/deprecated_command.rb +19 -0
- data/lib/knife-solo/info.rb +1 -1
- data/lib/knife-solo/kitchen_command.rb +5 -10
- data/lib/knife-solo/node_config_command.rb +17 -3
- data/lib/knife-solo/ssh_command.rb +3 -3
- data/test/bootstraps_test.rb +90 -0
- data/test/deprecated_command_test.rb +46 -0
- data/test/integration/cases/apache2_bootstrap.rb +15 -0
- data/test/integration/cases/apache2_cook.rb +28 -0
- data/test/integration/cases/empty_cook.rb +8 -0
- data/test/integration/cases/encrypted_data_bag.rb +27 -0
- data/test/integration/centos5_6_test.rb +19 -0
- data/test/integration/gentoo2011_test.rb +18 -0
- data/test/integration/omnios_r151004_test.rb +14 -0
- data/test/integration/scientific_linux_63_test.rb +15 -0
- data/test/integration/sles_11_test.rb +14 -0
- data/test/integration/ubuntu10_04_test.rb +15 -0
- data/test/integration/ubuntu12_04_bootstrap_test.rb +17 -0
- data/test/integration/ubuntu12_04_test.rb +15 -0
- data/test/integration_helper.rb +16 -0
- data/test/kitchen_command_test.rb +31 -0
- data/test/minitest/parallel.rb +41 -0
- data/test/node_config_command_test.rb +101 -0
- data/test/solo_bootstrap_test.rb +32 -0
- data/test/solo_clean_test.rb +12 -0
- data/test/solo_cook_test.rb +67 -0
- data/test/solo_init_test.rb +40 -0
- data/test/solo_prepare_test.rb +50 -0
- data/test/ssh_command_test.rb +100 -0
- data/test/support/config.yml.example +4 -0
- data/test/support/data_bag_key +1 -0
- data/test/support/ec2_runner.rb +122 -0
- data/test/support/integration_test.rb +94 -0
- data/test/support/issue_files/gentoo2011 +3 -0
- data/test/support/issue_files/sles11-sp1 +4 -0
- data/test/support/issue_files/ubuntu +2 -0
- data/test/support/kitchen_helper.rb +22 -0
- data/test/support/loggable.rb +18 -0
- data/test/support/secret_cookbook/metadata.rb +5 -0
- data/test/support/secret_cookbook/recipes/default.rb +8 -0
- data/test/support/ssh_config +3 -0
- data/test/support/test_case.rb +24 -0
- data/test/support/validation_helper.rb +39 -0
- data/test/test_helper.rb +7 -0
- metadata +99 -11
- data/lib/knife-solo/knife_solo_error.rb +0 -3
data/CHANGELOG.md
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
# 0.1.0: In progress
|
2
|
+
|
3
|
+
## Goals
|
4
|
+
|
5
|
+
* Cleaner bootstrap code
|
6
|
+
* Local integration testing
|
7
|
+
* Compatibility with plugins like knife-ec2
|
8
|
+
|
9
|
+
# Not released yet
|
10
|
+
|
11
|
+
* Move all commands under "knife solo" namespace (#118)
|
12
|
+
- Rename `knife kitchen` to `knife solo init`
|
13
|
+
- Rename `knife wash_up` to `knife solo clean`
|
14
|
+
* Add `knife solo bootstrap` command (#120)
|
15
|
+
* Detect Fedora 17 (#141)
|
16
|
+
* Improve help/error messages and validation (#142)
|
17
|
+
* Fix exit status of "cook" if chef-solo fails (#97)
|
18
|
+
|
19
|
+
## Thanks to our contributors!
|
20
|
+
|
21
|
+
* [Marek Hulan][ares]
|
22
|
+
|
23
|
+
# 0.0.15: November 29th, 2012
|
24
|
+
|
25
|
+
* Support for non-x86 omnibus (#137)
|
26
|
+
* Validate hostname in wash\_up (7a9115)
|
27
|
+
* Scientific Linux support (#131)
|
28
|
+
* Default to SSL omnibus URL (#130)
|
29
|
+
* Fixes for base debian installations (#129)
|
30
|
+
* Whyrun flag support (#123)
|
31
|
+
* Node-name flag support (#107)
|
32
|
+
* No More Syntax Check!! (#122)
|
33
|
+
|
34
|
+
* Various fixes: #138, #119, #113, d38bfd1
|
35
|
+
|
36
|
+
## Thanks to our contributors!
|
37
|
+
|
38
|
+
* [David Schneider][davidsch]
|
39
|
+
* [Andrew Vit][avit]
|
40
|
+
* [Nick Shortway][DrGonzo65]
|
41
|
+
* [Guido Serra aka Zeph][zeph]
|
42
|
+
* [Patrick Connolly][patcon]
|
43
|
+
* [Greg Fitzgerald][gregf]
|
44
|
+
* [Bryan McLellan][btm]
|
45
|
+
* [Aaron Jensen][aaronjensen]
|
46
|
+
|
47
|
+
And a special thanks to [Teemu Matilainen][tmatilai] who is now on the list of direct colaborators!
|
48
|
+
|
49
|
+
# 0.0.14: September 21st, 2012
|
50
|
+
|
51
|
+
* Fix argument checks (#101)
|
52
|
+
* Allow custom omnibus URLs (#99)
|
53
|
+
* Verbose logging options (#96)
|
54
|
+
|
55
|
+
## Thanks to our contributors!
|
56
|
+
|
57
|
+
* [Vaughan Rouesnel][vjpr]
|
58
|
+
* [Ryan Walker][ryandub]
|
59
|
+
* [Aaron Cruz][pferdefleisch]
|
60
|
+
|
61
|
+
# 0.0.13: August 16th, 2012
|
62
|
+
|
63
|
+
* Less agressive in-kitchen check (36a14161a1c)
|
64
|
+
* New curl/wget selection during omnibus install (#84)
|
65
|
+
* FreeBSD 9.0 support (#78)
|
66
|
+
* Syntax-check-only switch (#74)
|
67
|
+
* Validate CLI user/host args (#73)
|
68
|
+
|
69
|
+
## Thanks to our contributors!
|
70
|
+
|
71
|
+
* [Deepak Kannan][deepak]
|
72
|
+
* [Florian Unglaub][funglaub]
|
73
|
+
|
74
|
+
# 0.0.12: June 25th, 2012
|
75
|
+
|
76
|
+
* Better validation on CLI args (#68, #70)
|
77
|
+
* Switch from wget to curl (#66)
|
78
|
+
* Initial fedora support (not under integration) (#67)
|
79
|
+
* Support new omnibus path (/opt/chef)
|
80
|
+
|
81
|
+
## Thanks to our contributors!
|
82
|
+
|
83
|
+
* [Bryan Helmkamp][brynary]
|
84
|
+
* [Greg Fitzgerald][gregf]
|
85
|
+
* [Deepak Kannan][deepak]
|
86
|
+
|
87
|
+
# 0.0.11: June 16th, 2012
|
88
|
+
|
89
|
+
* Encrypted data bag support (#22)
|
90
|
+
* Updated dependency version (#63, #64)
|
91
|
+
* Joyent Ubuntu detection (#62)
|
92
|
+
* Omnibus version selection (#61)
|
93
|
+
|
94
|
+
## Thanks to our contributors!
|
95
|
+
|
96
|
+
* [Hector Castro][hectcastro]
|
97
|
+
* [Sean Porter][portertech]
|
98
|
+
|
99
|
+
# 0.0.10: May 30th, 2012
|
100
|
+
|
101
|
+
* Include apache recipe during integration testing (#17)
|
102
|
+
* Use omnibus installer on Ubuntu and RedHat (#40, #45, #58)
|
103
|
+
* `knife wash_up` command for removing uploaded resources (#48)
|
104
|
+
* Cleaner sudo pre-processing (#59)
|
105
|
+
* Support `knife kitchen .` to init an existing kitchen (#54)
|
106
|
+
|
107
|
+
## Thanks to our contributors!
|
108
|
+
|
109
|
+
* [Hector Castro][hectcastro]
|
110
|
+
* [Nix-wie-weg][Nix-wie-weg]
|
111
|
+
* [Justin Grevich][jgrevich]
|
112
|
+
* [Ross Timson][rosstimson]
|
113
|
+
|
114
|
+
# 0.0.9: May 13th, 2012
|
115
|
+
|
116
|
+
* Chef 0.10.10 compatibility (b0fa50e9)
|
117
|
+
* Finished support and integration testing for remaining key OSes (Issues #2 and #15)
|
118
|
+
* Added support for 'chefignore' (e4bcbd1..4b578cf9)
|
119
|
+
* Use `lsb_release` to detect OSes where possible (c976cc119..a31d8234b)
|
120
|
+
* Ignore `tmp` and `deploy_revision` to rsync exclusion (7d252ff2b)
|
121
|
+
|
122
|
+
## Thanks to our contributors!
|
123
|
+
|
124
|
+
* [Hector Castro][hectcastro]
|
125
|
+
* [Amos Lanka][amoslanka]
|
126
|
+
* [Roland Moriz][rmoriz]
|
127
|
+
* [Tyler Rick][TylerRick]
|
128
|
+
* [Motiejus Jakštys][Motiejus]
|
129
|
+
|
130
|
+
# 0.0.8: February 10, 2012
|
131
|
+
|
132
|
+
* Add --startup-script which gets sourced before any command to setup env vars (e.g., ~/.bashrc) (d1489f94)
|
133
|
+
* Use curl + rpm rather than rpm against direct URL for better proxy support (51ad9c51)
|
134
|
+
* Integration harness improvements (1ac5cce..4be36c2)
|
135
|
+
* BUG #10: Create .gitkeep's to avoid errors on sparse kitchens (074b4e0a)
|
136
|
+
* Add --skip-chef-check knife option (a1a66ae)
|
137
|
+
|
138
|
+
## Thanks to our contributors!
|
139
|
+
|
140
|
+
* [Cyril Ledru][patatepartie]
|
141
|
+
* [Fletcher Nichol][fnichol]
|
142
|
+
* [Jason Garber][jgarber]
|
143
|
+
* [Greg Sterndale][gsterndale]
|
144
|
+
|
145
|
+
# 0.0.7: Dec 9, 2011
|
146
|
+
|
147
|
+
* BUG #9: Fix intelligent sudo handling for OSes that don't have it
|
148
|
+
* Move integration tests into proper test cases
|
149
|
+
* CentOS 5.6 integration test
|
150
|
+
|
151
|
+
# 0.0.6: Dec 8, 2011
|
152
|
+
|
153
|
+
* Support for Mac OS 10.5 and 10.6 (00921ebd1b93)
|
154
|
+
* Parallel integration testing and SLES (167360d447..167360d447)
|
155
|
+
* Dynamic sudo detection for yum-based systems (5282fc36ac3..256f27658a06cb)
|
156
|
+
|
157
|
+
## Thanks to our contributors!
|
158
|
+
|
159
|
+
* [Sergio Rubio][rubiojr]
|
160
|
+
* [Nat Lownes][natlownes]
|
161
|
+
|
162
|
+
# 0.0.5: Oct 31, 2011
|
163
|
+
|
164
|
+
* Started on integration testing via EC2
|
165
|
+
* Add openSuSE support. Installation via zypper. (64ff2edf42)
|
166
|
+
* Upgraded Rubygems to 1.8.10 (8ac1f4d43a)
|
167
|
+
|
168
|
+
# 0.0.4: Oct 7, 2011
|
169
|
+
|
170
|
+
* Chef 0.10.4 based databag and search method (a800880e6d)
|
171
|
+
* Proper path for roles (b143ae290a)
|
172
|
+
* Test fixes for CI compatibility (ccf4247125..62b8bd498d)
|
173
|
+
|
174
|
+
## Thanks to our contributors!
|
175
|
+
|
176
|
+
* [John Dewey][retr0h]
|
177
|
+
|
178
|
+
# 0.0.3: July 31, 2011
|
179
|
+
|
180
|
+
* Kitchen directory generation
|
181
|
+
* Prepare tested on ubuntu
|
182
|
+
* Generate node config on prepare
|
183
|
+
* Cook via rsync
|
184
|
+
|
185
|
+
[DrGonzo65]: https://github.com/DrGonzo65
|
186
|
+
[Motiejus]: https://github.com/Motiejus
|
187
|
+
[Nix-wie-weg]: https://github.com/Nix-wie-weg
|
188
|
+
[TylerRick]: https://github.com/TylerRick
|
189
|
+
[aaronjensen]: https://github.com/aaronjensen
|
190
|
+
[amoslanka]: https://github.com/amoslanka
|
191
|
+
[ares]: https://github.com/ares
|
192
|
+
[avit]: https://github.com/avit
|
193
|
+
[brynary]: https://github.com/brynary
|
194
|
+
[btm]: https://github.com/btm
|
195
|
+
[davidsch]: https://github.com/davidsch
|
196
|
+
[deepak]: https://github.com/deepak
|
197
|
+
[fnichol]: https://github.com/fnichol
|
198
|
+
[funglaub]: https://github/funglaub
|
199
|
+
[gregf]: https://github.com/gregf
|
200
|
+
[gsterndale]: https://github.com/gsterndale
|
201
|
+
[hectcastro]: https://github.com/hectcastro
|
202
|
+
[jgarber]: https://github.com/jgarber
|
203
|
+
[jgrevich]: https://github.com/jgrevich
|
204
|
+
[natlownes]: https://github.com/natlownes
|
205
|
+
[patatepartie]: https://github.com/patatepartie
|
206
|
+
[patcon]: https://github.com/patcon
|
207
|
+
[pferdefleisch]: https://github.com/pferdefleisch
|
208
|
+
[portertech]: https://github.com/portertech
|
209
|
+
[retr0h]: https://github.com/retr0h
|
210
|
+
[rmoriz]: http://github.com/rmoriz
|
211
|
+
[rosstimson]: https://github.com/rosstimson
|
212
|
+
[rubiojr]: https://github.com/rubiojr
|
213
|
+
[ryandub]: https://github.com/ryandub
|
214
|
+
[tmatilai]: https://github.com/tmatilai
|
215
|
+
[vjpr]: https://github.com/vjpr
|
216
|
+
[zeph]: https://github.com/zeph
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2011 Mat Schaffer <mat@schaffer.me>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
= knife-solo
|
2
|
+
|
3
|
+
{<img src="https://secure.travis-ci.org/matschaffer/knife-solo.png" alt="Build Status" />}[http://travis-ci.org/matschaffer/knife-solo]
|
4
|
+
{<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/matschaffer/knife-solo]
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
Knife-solo is a gem plugin for Chef's knife utility. It currently adds 5 subcommands to knife:
|
9
|
+
|
10
|
+
- <tt>knife solo init</tt> is used to create a new directory structure (i.e. "kitchen") that fits with Chef's standard structure and can be used to build and store recipes.
|
11
|
+
|
12
|
+
- <tt>knife solo prepare</tt> installs Chef on a given host. It's structured to auto-detect the target OS and change the installation process accordingly.
|
13
|
+
|
14
|
+
- <tt>knife solo cook</tt> uploads the current kitchen (Chef repo) to the target host and runs chef-solo on that host.
|
15
|
+
|
16
|
+
- <tt>knife solo bootstrap</tt> combines the two previous ones (prepare and cook).
|
17
|
+
|
18
|
+
- <tt>knife solo clean</tt> removes the uploaded kitchen from the target host.
|
19
|
+
|
20
|
+
Preliminary Windows support for "knife solo cook" is available (see below).
|
21
|
+
|
22
|
+
== USAGE:
|
23
|
+
|
24
|
+
Installation is a normal gem installation.
|
25
|
+
|
26
|
+
gem install knife-solo
|
27
|
+
|
28
|
+
If you need to install from git run:
|
29
|
+
|
30
|
+
rake install
|
31
|
+
|
32
|
+
=== Init command
|
33
|
+
|
34
|
+
The init command simply takes a name of the directory to store the kitchen structure. Use "." to initialize the current directory.
|
35
|
+
|
36
|
+
knife init mychefrepo
|
37
|
+
|
38
|
+
Currently the directory structure looks like this, but could change as development continues.
|
39
|
+
|
40
|
+
mychefrepo/
|
41
|
+
├── cookbooks
|
42
|
+
├── data_bags
|
43
|
+
├── nodes
|
44
|
+
├── roles
|
45
|
+
├── site-cookbooks
|
46
|
+
└── solo.rb
|
47
|
+
|
48
|
+
=== Prepare command
|
49
|
+
|
50
|
+
The prepare command takes an ssh-style host argument as follows:
|
51
|
+
|
52
|
+
knife solo prepare ubuntu@10.0.0.201
|
53
|
+
|
54
|
+
It will look up SSH information from <tt>~/.ssh/config</tt> or in the file specified by +-F+. You can also pass port information (+-p+), identity information (+-i+), or a password (+-P+). It will use sudo to run some of these commands and will prompt you for the password if it's not supplied on the command line.
|
55
|
+
|
56
|
+
This command will make a best-effort to detect and install Chef Solo on your target operating system. We use the {Opscode Installer}[http://www.opscode.com/chef/install/] wherever possible.
|
57
|
+
|
58
|
+
If you need specific behavior you can fallback to a knife bootstrap command with an empty runlist using the following:
|
59
|
+
|
60
|
+
knife bootstrap --template-file bootstrap.centos.erb -u root 172.16.144.132
|
61
|
+
echo '{"run_list":[]}' > nodes/172.16.144.132.json
|
62
|
+
|
63
|
+
Bootstrap templates are quite simple, as shown in {this gist for bootstrap.centos.erb}[https://gist.github.com/2402433].
|
64
|
+
|
65
|
+
Or if your modifications provide some general benefit, consider sending a pull request to {this project}[https://github.com/matschaffer/knife-solo] or {the omnibus installer}[https://github.com/opscode/omnibus].
|
66
|
+
|
67
|
+
=== Cook command
|
68
|
+
|
69
|
+
The cook command also takes an ssh-style host argument:
|
70
|
+
|
71
|
+
knife solo cook ubuntu@10.0.0.201
|
72
|
+
|
73
|
+
The cook command uploads the current kitchen to the server and runs chef-solo on that server. If you only specify one argument it will look for a node config in <tt>nodes/<hostname>.json</tt>. Or if you want to specify a node config you can pass the path to the file as the second argument.
|
74
|
+
|
75
|
+
This uploads all of your cookbooks in addition to a patch that allows you to use data_bags in a read-only fashion from the +data_bags+ folder.
|
76
|
+
|
77
|
+
This also supports encrypted data bags. To use them, place your key in +data_bag_key+ in the root of your kitchen (or if you move it make sure to update +solo.rb+ to reflect the new path).
|
78
|
+
|
79
|
+
The knife command for creating encrypted data bags doesn't work well without a Chef server, so use {this gist}[https://gist.github.com/2896172] as an example on how to create encrypted data bag items on your local file system.
|
80
|
+
|
81
|
+
=== Bootstrap command
|
82
|
+
|
83
|
+
The bootstrap command takes the same arguments and most of the options as prepare and cook:
|
84
|
+
|
85
|
+
knife solo bootstrap ubuntu@10.0.0.201
|
86
|
+
|
87
|
+
Under the hood it first calls +knife solo prepare+ and then +knife solo cook+ with the specified arguments and options.
|
88
|
+
|
89
|
+
=== Clean command
|
90
|
+
|
91
|
+
The clean command takes the same arguments like prepare and cook:
|
92
|
+
|
93
|
+
knife solo clean ubuntu@10.0.0.201
|
94
|
+
|
95
|
+
The clean command removes an uploaded kitchen completely from the target host. This improves security because passwords etc. are not left behind on that host.
|
96
|
+
|
97
|
+
=== Windows support
|
98
|
+
|
99
|
+
The cook command will work on Windows node if you meet the following howto:
|
100
|
+
|
101
|
+
==== Init then tweak
|
102
|
+
|
103
|
+
- run <tt>knife solo init</tt> then edit solo.rb to use Windows path-naming (see https://gist.github.com/1773854)
|
104
|
+
|
105
|
+
==== Prepare the node manually
|
106
|
+
|
107
|
+
- install a SSH server (eg: WinSSHd)
|
108
|
+
- install rsync on the node (see https://github.com/thbar/rsync-windows)
|
109
|
+
- add rsync to the user PATH
|
110
|
+
- install http://www.opscode.com/chef/install.msi
|
111
|
+
- add nodes/hostname.json and put <tt>{ "run_list": [] }</tt> in it
|
112
|
+
|
113
|
+
==== Cook
|
114
|
+
|
115
|
+
- cook should work as expected automatically, if you use cygwin rsync
|
116
|
+
|
117
|
+
== DEVELOPMENT
|
118
|
+
|
119
|
+
Get set up by running +./script/newb+ this will do some of the steps and guide you through the rest. If it doesn't run for you, feel free to {file an issue}[https://github.com/matschaffer/knife-solo/issues].
|
120
|
+
|
121
|
+
When running integration tests all output is sent to the log directory into a file that matches matches the test case name. The EC2Runner log is the main runner log that contains information about instance provisioning.
|
122
|
+
|
123
|
+
Note that instances will remain running until your tests pass. This aids in speeding up the test cycle. Upon succesfful test completion you'll be given 10 seconds to cancel the process before the instances are cleaned up. Note that any instance tagged with <tt>knife_solo_integration_user == $USER</tt> will be cleaned up. Or if you want to leave your instances running regardless, specify <tt>SKIP_DESTROY=true</tt> as an environment variable.
|
124
|
+
|
125
|
+
To make an integration test, create a file in the +test/integration+ directory and a test class that inherits from +IntegrationTest+ and includes a module from +test/integration/cases+. You can override methods as necessary, but generally you only need to override +user+ and +image_id+ to specify the user name and AMI ID.
|
126
|
+
|
127
|
+
If you're interested in contributing, contact me via GitHub or have a look at the {GitHub issues page}[https://github.com/matschaffer/knife-solo/issues].
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
desc 'Updates Manifest.txt with a list of files from git'
|
5
|
+
task :manifest do
|
6
|
+
git_files = `git ls-files`.split("\n")
|
7
|
+
ignored = %w(.gitignore Gemfile Gemfile.lock Manifest.txt knife-solo.gemspec script/newb script/test)
|
8
|
+
|
9
|
+
File.open('Manifest.txt', 'w') do |f|
|
10
|
+
f.puts (git_files - ignored).join("\n")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
task :release => :manifest
|
15
|
+
|
16
|
+
namespace :test do
|
17
|
+
Rake::TestTask.new(:integration) do |t|
|
18
|
+
t.libs << "test"
|
19
|
+
t.test_files = FileList['test/integration/*_test.rb']
|
20
|
+
end
|
21
|
+
|
22
|
+
Rake::TestTask.new(:units) do |t|
|
23
|
+
t.libs << "test"
|
24
|
+
t.test_files = FileList['test/*_test.rb']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Alias for test:units"
|
29
|
+
task :test => ['test:units']
|
30
|
+
task :default => :test
|
31
|
+
|
data/lib/chef/knife/cook.rb
CHANGED
@@ -1,137 +1,10 @@
|
|
1
|
-
require 'chef/knife'
|
2
|
-
|
3
|
-
require 'knife-solo/ssh_command'
|
4
|
-
require 'knife-solo/kitchen_command'
|
5
|
-
require 'knife-solo/node_config_command'
|
6
|
-
require 'knife-solo/tools'
|
1
|
+
require 'chef/knife/solo_cook'
|
2
|
+
require 'knife-solo/deprecated_command'
|
7
3
|
|
8
4
|
class Chef
|
9
5
|
class Knife
|
10
|
-
|
11
|
-
|
12
|
-
class Cook < Knife
|
13
|
-
OMNIBUS_EMBEDDED_PATHS = ["/opt/chef/embedded/bin", "/opt/opscode/embedded/bin"]
|
14
|
-
OMNIBUS_EMBEDDED_GEM_PATHS = ["/opt/chef/embedded/lib/ruby/gems/1.9.1", "/opt/opscode/embedded/lib/ruby/gems/1.9.1"]
|
15
|
-
CHEF_VERSION_CONSTRAINT = ">=0.10.4"
|
16
|
-
|
17
|
-
include KnifeSolo::SshCommand
|
18
|
-
include KnifeSolo::KitchenCommand
|
19
|
-
include KnifeSolo::NodeConfigCommand
|
20
|
-
include KnifeSolo::Tools
|
21
|
-
|
22
|
-
deps do
|
23
|
-
require 'chef/cookbook/chefignore'
|
24
|
-
require 'pathname'
|
25
|
-
KnifeSolo::SshCommand.load_deps
|
26
|
-
KnifeSolo::NodeConfigCommand.load_deps
|
27
|
-
end
|
28
|
-
|
29
|
-
banner "knife cook [user@]hostname [json] (options)"
|
30
|
-
|
31
|
-
option :skip_chef_check,
|
32
|
-
:long => '--skip-chef-check',
|
33
|
-
:boolean => true,
|
34
|
-
:description => "Skip the version check on the Chef gem"
|
35
|
-
|
36
|
-
option :sync_only,
|
37
|
-
:long => '--sync-only',
|
38
|
-
:boolean => false,
|
39
|
-
:description => "Only sync the cookbook - do not run Chef"
|
40
|
-
|
41
|
-
option :why_run,
|
42
|
-
:short => '-W',
|
43
|
-
:long => '--why-run',
|
44
|
-
:boolean => true,
|
45
|
-
:description => "Enable whyrun mode"
|
46
|
-
|
47
|
-
def run
|
48
|
-
time('Run') do
|
49
|
-
validate_params!
|
50
|
-
super
|
51
|
-
Chef::Config.from_file('solo.rb')
|
52
|
-
check_chef_version unless config[:skip_chef_check]
|
53
|
-
generate_node_config
|
54
|
-
rsync_kitchen
|
55
|
-
add_patches
|
56
|
-
cook unless config[:sync_only]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def chef_path
|
61
|
-
Chef::Config.file_cache_path
|
62
|
-
end
|
63
|
-
|
64
|
-
def chefignore
|
65
|
-
@chefignore ||= ::Chef::Cookbook::Chefignore.new("./")
|
66
|
-
end
|
67
|
-
|
68
|
-
# cygwin rsync path must be adjusted to work
|
69
|
-
def adjust_rsync_path(path)
|
70
|
-
return path unless windows_node?
|
71
|
-
path.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
|
72
|
-
end
|
73
|
-
|
74
|
-
def patch_path
|
75
|
-
Array(Chef::Config.cookbook_path).first + "/chef_solo_patches/libraries"
|
76
|
-
end
|
77
|
-
|
78
|
-
def rsync_exclude
|
79
|
-
(%w{revision-deploys tmp '.*'} + chefignore.ignores).uniq
|
80
|
-
end
|
81
|
-
|
82
|
-
def debug?
|
83
|
-
config[:verbosity] and config[:verbosity] > 0
|
84
|
-
end
|
85
|
-
|
86
|
-
# Time a command
|
87
|
-
def time(msg)
|
88
|
-
return yield unless debug?
|
89
|
-
ui.msg "Starting '#{msg}'"
|
90
|
-
start = Time.now
|
91
|
-
yield
|
92
|
-
ui.msg "#{msg} finished in #{Time.now - start} seconds"
|
93
|
-
end
|
94
|
-
|
95
|
-
def rsync_kitchen
|
96
|
-
time('Rsync kitchen') do
|
97
|
-
cmd = %Q{rsync -rl --rsh="ssh #{ssh_args}" --delete #{rsync_exclude.collect{ |ignore| "--exclude #{ignore} " }.join} ./ :#{adjust_rsync_path(chef_path)}}
|
98
|
-
ui.msg cmd if debug?
|
99
|
-
system! cmd
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def add_patches
|
104
|
-
run_portable_mkdir_p(patch_path)
|
105
|
-
Dir[Pathname.new(__FILE__).dirname.join("patches", "*.rb").to_s].each do |patch|
|
106
|
-
time(patch) do
|
107
|
-
system! %Q{rsync -rl --rsh="ssh #{ssh_args}" #{patch} :#{adjust_rsync_path(patch_path)}}
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def check_chef_version
|
113
|
-
ui.msg "Checking Chef version..."
|
114
|
-
result = run_command <<-BASH
|
115
|
-
export PATH="#{OMNIBUS_EMBEDDED_PATHS.join(":")}:$PATH"
|
116
|
-
export GEM_PATH="#{OMNIBUS_EMBEDDED_GEM_PATHS.join(":")}:$GEM_PATH"
|
117
|
-
ruby -rubygems -e "gem 'chef', '#{CHEF_VERSION_CONSTRAINT}'"
|
118
|
-
BASH
|
119
|
-
raise "Couldn't find Chef #{CHEF_VERSION_CONSTRAINT} on #{host}. Please run `#{$0} prepare #{ssh_args}` to ensure Chef is installed and up to date." unless result.success?
|
120
|
-
end
|
121
|
-
|
122
|
-
def cook
|
123
|
-
cmd = "sudo chef-solo -c #{chef_path}/solo.rb -j #{chef_path}/#{node_config}"
|
124
|
-
cmd << " -l debug" if debug?
|
125
|
-
cmd << " -N #{config[:chef_node_name]}" if config[:chef_node_name]
|
126
|
-
cmd << " -W" if config[:why_run]
|
127
|
-
|
128
|
-
stream_command cmd
|
129
|
-
end
|
130
|
-
|
131
|
-
def validate_params!
|
132
|
-
validate_first_cli_arg_is_a_hostname!
|
133
|
-
end
|
134
|
-
|
6
|
+
class Cook < SoloCook
|
7
|
+
include KnifeSolo::DeprecatedCommand
|
135
8
|
end
|
136
9
|
end
|
137
10
|
end
|