chef-workflow-tasklib 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +22 -0
- data/LICENSE.txt +2 -2
- data/README.md +32 -233
- data/chef-workflow-tasklib.gemspec +2 -3
- data/lib/chef-workflow-tasklib.rb +6 -8
- data/lib/chef-workflow-tasklib/version.rb +3 -5
- data/lib/chef-workflow/task-helpers/ssh.rb +11 -0
- data/lib/chef-workflow/task-helpers/with_scheduler.rb +20 -0
- data/lib/chef-workflow/tasks/bootstrap/db.rb +7 -0
- data/lib/chef-workflow/tasks/bootstrap/knife.rb +1 -1
- data/lib/chef-workflow/tasks/chef/build.rb +34 -0
- data/lib/chef-workflow/tasks/chef/clean.rb +4 -25
- data/lib/chef-workflow/tasks/chef/converge.rb +12 -0
- data/lib/chef-workflow/tasks/chef/cookbooks/foodcritic.rb +18 -0
- data/lib/chef-workflow/tasks/{cookbooks → chef/cookbooks}/resolve/berkshelf.rb +0 -0
- data/lib/chef-workflow/tasks/chef/cookbooks/resolve/berkshelf/berkshelf-base.rb +23 -0
- data/lib/chef-workflow/tasks/{cookbooks → chef/cookbooks}/resolve/berkshelf0.4.rb +0 -0
- data/lib/chef-workflow/tasks/chef/cookbooks/resolve/bootstrap.rb +7 -0
- data/lib/chef-workflow/tasks/chef/cookbooks/resolve/librarian.rb +23 -0
- data/lib/chef-workflow/tasks/chef/cookbooks/upload.rb +13 -0
- data/lib/chef-workflow/tasks/chef/data_bags.rb +16 -6
- data/lib/chef-workflow/tasks/chef/environments.rb +14 -3
- data/lib/chef-workflow/tasks/chef/info.rb +67 -0
- data/lib/chef-workflow/tasks/chef/roles.rb +2 -2
- data/lib/chef-workflow/tasks/chef/upload.rb +2 -2
- data/lib/chef-workflow/tasks/chef_server.rb +28 -27
- data/lib/chef-workflow/tasks/default.rb +4 -2
- data/lib/chef-workflow/tasks/test.rb +32 -42
- data/lib/chef-workflow/tasks/test/build.rb +8 -17
- metadata +21 -33
- data/lib/chef-workflow/tasks/chef/show_config.rb +0 -38
- data/lib/chef-workflow/tasks/cookbooks/foodcritic.rb +0 -16
- data/lib/chef-workflow/tasks/cookbooks/resolve/berkshelf/berkshelf-base.rb +0 -21
- data/lib/chef-workflow/tasks/cookbooks/resolve/bootstrap.rb +0 -10
- data/lib/chef-workflow/tasks/cookbooks/resolve/librarian.rb +0 -21
- data/lib/chef-workflow/tasks/cookbooks/resolve_and_upload.rb +0 -6
- data/lib/chef-workflow/tasks/cookbooks/upload.rb +0 -10
data/CHANGELOG.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
* 0.2.0 (unreleased)
|
2
|
+
* **breaking change**: the 'cookbooks' namespace has been moved to chef:cookbooks
|
3
|
+
* chef:build builds a server or set of servers based on a server group. Uses
|
4
|
+
the provisioner and scheduler, and is tracked no differently than
|
5
|
+
provisions from tests or the chef server.
|
6
|
+
* task helpers: with_scheduler and all the bits from SSHHelper in testlib are now available to rake tasks.
|
7
|
+
* chef:converge, given a server group runs chef-client on it.
|
8
|
+
* chef:info namespace created:
|
9
|
+
* chef:show_config is now chef:info:config
|
10
|
+
* chef:info:ips shows external IP assignments by server group
|
11
|
+
* chef:info:provisioned shows information about the provisioned machines
|
12
|
+
* Tasks have been re-written to exploit the refactors in chef-workflow
|
13
|
+
* test:full task has some different semantics which make it more suitable for CI:
|
14
|
+
* test:recipes is a part of the dependency list
|
15
|
+
* always runs chef:clean before doing anything
|
16
|
+
* If a resolver is used, `chef:upload` always invokes it before doing anything
|
17
|
+
|
18
|
+
* 0.1.1 December 21, 2012
|
19
|
+
* Fix gemspec. Here's to touching the stove.
|
20
|
+
|
21
|
+
* 0.1.0 December 21, 2012
|
22
|
+
* Initial public release
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2012 Erik Hollensbe
|
1
|
+
Copyright (c) 2012, 2013 Erik Hollensbe
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
Chef Workflow - Rake Tasks & Support
|
2
|
+
------------------------------------
|
2
3
|
|
3
4
|
This gem provides a set of rake tasks broken up logically to support a chef
|
4
5
|
workflow, and tooling to assist with driving those tasks. It is intended to
|
5
|
-
complement a chef repository
|
6
|
+
complement a chef repository to keep interaction between multiple consumers of
|
7
|
+
it fairly uniform.
|
6
8
|
|
7
9
|
Some of the tasks it provides are:
|
8
10
|
|
@@ -17,244 +19,41 @@ Some of the tasks it provides are:
|
|
17
19
|
* Running unit tests against networks of provisioned machines -- see
|
18
20
|
[chef-workflow-testlib](https://github.com/chef-workflow/chef-workflow-testlib)
|
19
21
|
for more information.
|
22
|
+
* Create machines on the fly that know about your chef server, work with them
|
23
|
+
in a change/converge/inspect cycle, all without having to fire up a ton of
|
24
|
+
machines each time or even have to care about where they live or worry about
|
25
|
+
forgetting to tear them down. We track that for you.
|
20
26
|
|
21
|
-
|
27
|
+
Most of the Meat is on the Wiki
|
28
|
+
-------------------------------
|
22
29
|
|
23
|
-
|
24
|
-
|
25
|
-
this.** Write your own tasks, use a subset of our tasks, configure our tasks to
|
26
|
-
use your settings, or even adjust what happens when you just type `rake`. The
|
27
|
-
whole system is built to accomodate this.
|
30
|
+
This project is a part of
|
31
|
+
[chef-workflow](https://github.com/chef-workflow/chef-workflow).
|
28
32
|
|
29
|
-
|
33
|
+
Our [wiki](https://github.com/chef-workflow/chef-workflow/wiki) contains
|
34
|
+
a fair amount of information, including how to try chef-workflow without
|
35
|
+
actually doing anything more than cloning a repository and running a few
|
36
|
+
commands.
|
30
37
|
|
31
|
-
|
32
|
-
|
33
|
-
lives in your repository.
|
38
|
+
Contributing
|
39
|
+
------------
|
34
40
|
|
35
|
-
|
41
|
+
* fork the project
|
42
|
+
* make a branch
|
43
|
+
* add your stuff
|
44
|
+
* push your branch to your repo
|
45
|
+
* send a pull request
|
36
46
|
|
37
|
-
|
47
|
+
**Note:** modifications to gem metadata, author lists, and other credits
|
48
|
+
without rationale will be rejected immediately.
|
38
49
|
|
39
|
-
|
50
|
+
Credits
|
51
|
+
-------
|
40
52
|
|
41
|
-
|
53
|
+
Author: [Erik Hollensbe](https://github.com/erikh)
|
42
54
|
|
43
|
-
|
44
|
-
|
55
|
+
These companies have assisted by donating time, financial resources, and
|
56
|
+
employment to those working on chef-workflow. Supporting OSS is really really
|
57
|
+
cool and we should reciprocate.
|
45
58
|
|
46
|
-
|
47
|
-
|
48
|
-
If you already had a `Rakefile`, it will not be modified. To use the tasks, add
|
49
|
-
these two lines to your `Rakefile`:
|
50
|
-
|
51
|
-
```ruby
|
52
|
-
require 'chef-workflow-tasklib'
|
53
|
-
chef_workflow_task 'default'
|
54
|
-
```
|
55
|
-
|
56
|
-
Then to see all the tasks use:
|
57
|
-
|
58
|
-
$ bundle exec rake -T
|
59
|
-
|
60
|
-
**Note:** `rake` by itself will **not work**. We depend on newer gems than the
|
61
|
-
`rake` that's included with ruby does, which is what will be used if you do not
|
62
|
-
execute `bundle exec rake`. At this point bundler runs, and will fail because
|
63
|
-
`rake` will have activated gems that your bundle will be incompatible with.
|
64
|
-
|
65
|
-
If this is confusing, just remember to always `bundle exec rake` and you won't
|
66
|
-
have any trouble.
|
67
|
-
|
68
|
-
You should see something similar to this:
|
69
|
-
|
70
|
-
```
|
71
|
-
rake chef:clean # Clean up the state files that chef-workflow generates
|
72
|
-
rake chef:clean:ips # Clean up the ip registry for chef-workflow
|
73
|
-
rake chef:clean:knife # Clean up the temporary chef configuration for chef-workflow
|
74
|
-
rake chef:clean:prisons # Clean up the prison registry for chef-workflow
|
75
|
-
rake chef:environments:upload # Upload your environments to the chef server
|
76
|
-
rake chef:roles:upload # Upload your roles to the chef server
|
77
|
-
rake chef:show_config # Show the calculated configuration for chef-workflow
|
78
|
-
rake chef_server:build_knife_config # Create and write a knife configuration suitable for creating new chef servers.
|
79
|
-
rake chef_server:create:vagrant # Create a chef server in a vagrant machine.
|
80
|
-
rake chef_server:destroy:vagrant # Destroy the last chef server created with vagrant
|
81
|
-
rake cookbooks:update # Update your locked cookbooks with Berkshelf
|
82
|
-
rake cookbooks:upload # Upload your cookbooks to the chef server
|
83
|
-
rake test # Run tests
|
84
|
-
rake test:build # test:refresh and test
|
85
|
-
rake test:refresh # Refresh all global meta on the chef server
|
86
|
-
rake test:vagrant:full # Build a chef server with vagrant, run test:build, destroy the chef server
|
87
|
-
```
|
88
|
-
|
89
|
-
Last step: add `.chef-workflow` to `.gitignore`. You can change this, but
|
90
|
-
until you've done that, it's going to write things to this directory.
|
91
|
-
|
92
|
-
If you want to do a full test run at this point (which with no tests will do
|
93
|
-
nothing but build a chef server and tear it down), feel free to:
|
94
|
-
|
95
|
-
$ bundle exec test:vagrant:full
|
96
|
-
|
97
|
-
## Notes on dependencies
|
98
|
-
|
99
|
-
As of this writing, the workflow has some pretty strict requirements that we
|
100
|
-
hope to make more flexible in the near future. Until then, you should be aware
|
101
|
-
of a few things:
|
102
|
-
|
103
|
-
* Chef 10.16.2 is required. This isn't actually necessary as mentioned above,
|
104
|
-
and will be resolved as soon as I can find time to test with earlier
|
105
|
-
versions. This has some implications:
|
106
|
-
|
107
|
-
* Tools like `berkshelf` and `librarian` and `foodcritic` (all add-ins to
|
108
|
-
the default workflow) have hard dependencies on earlier versions of chef.
|
109
|
-
The tasks that integrate these take this into account, but **you must
|
110
|
-
install the gems separately and manually to use them**.
|
111
|
-
|
112
|
-
* Ruby 1.9 is **required**. We will gladly accept patches to make it 1.8.7
|
113
|
-
compatible, but 1.8.7 compatibility is not something we will be actively
|
114
|
-
pursuing at this point.
|
115
|
-
|
116
|
-
## Usage
|
117
|
-
|
118
|
-
Everything in this workflow is managed through usage of `rake` tasks, with an
|
119
|
-
emphasis on cherry-picking tasks with `chef_workflow_task` into your `Rakefile` and
|
120
|
-
configuring them with support configurators like `configure_knife` and
|
121
|
-
`configure_vagrant`.
|
122
|
-
|
123
|
-
The next few sections will briefly cover the high-level design of the system.
|
124
|
-
For details, or information on writing your own tasks, hit the
|
125
|
-
[wiki](https://github.com/chef-workflow/chef-workflow-tasklib/wiki).
|
126
|
-
|
127
|
-
For the basic workflow, note that everything is state tracked between runs for
|
128
|
-
the most part, so if you build a chef server with `chef_server:create`,
|
129
|
-
other tasks will just do the right thing and operate on that chef server. This
|
130
|
-
makes it easy to maintain a edit, upload, test, evaluate, repeat workflow as
|
131
|
-
you're working on changes. Knife configuration, vagrant "prisons" (See the
|
132
|
-
wiki) and allocated IPs are all tracked on exit in the `.chef-workflow`
|
133
|
-
directory.
|
134
|
-
|
135
|
-
There are some environment variables which control various settings, like
|
136
|
-
debugging output. The defaults are usually fine, but check out the "Environment
|
137
|
-
Variables" section of the
|
138
|
-
[chef-workflow](https://github.com/chef-workflow/chef-workflow) `README.md`.
|
139
|
-
|
140
|
-
## Picking your own workflow
|
141
|
-
|
142
|
-
Adding `chef_workflow_task` statements to your workflow is the easiest way to get started.
|
143
|
-
We don't expect you to use a resolver, for example, but support both
|
144
|
-
[Berkshelf](https://github.com/RiotGames/Berkshelf) and
|
145
|
-
[Librarian](https://github.com/applicationsonline/librarian) out of the box.
|
146
|
-
Neither of these are required in the default `chef-workflow` require.
|
147
|
-
|
148
|
-
Many tasks exist in our [tasks
|
149
|
-
directory](https://github.com/chef-workflow/chef-workflow-tasklib/tree/master/lib/chef-workflow/tasks)
|
150
|
-
and we strongly recommend poking through it if you're interested in fully
|
151
|
-
customizing your workflow. Every attempt has been made for each task library to
|
152
|
-
pull in only what it needs to operate which allows you to use each independent
|
153
|
-
portion without fear of missing essential code.
|
154
|
-
|
155
|
-
So to add `berkshelf` support, we add this to our Rakefile:
|
156
|
-
|
157
|
-
```ruby
|
158
|
-
chef_workflow_task 'cookbooks/resolve/berkshelf'
|
159
|
-
```
|
160
|
-
|
161
|
-
(If you are using berkshelf 0.4.x or earlier, `chef_workflow_task
|
162
|
-
'cookbooks/resolve/berkshelf0.4'`)
|
163
|
-
|
164
|
-
Which will add a few tasks, `cookbooks:resolve` and `cookbooks:update` and a
|
165
|
-
few dependencies. **Note:** due to the way many of these tools declare
|
166
|
-
dependencies, they must be installed independently of the bundle with `gem
|
167
|
-
install`, so in this case, `gem install berkshelf`. This is out of our control.
|
168
|
-
|
169
|
-
Let's build a custom workflow. For example let's say we just want to add:
|
170
|
-
|
171
|
-
* resolving cookbooks with librarian
|
172
|
-
* uploading cookbooks
|
173
|
-
* uploading roles
|
174
|
-
* uploading environments
|
175
|
-
* uploading data bags
|
176
|
-
* a task that does all of these when we type `bundle exec rake`
|
177
|
-
|
178
|
-
*You'll have to point this at your live knife configuration* (see the next
|
179
|
-
section), but your `Rakefile` would at first look something like this:
|
180
|
-
|
181
|
-
```ruby
|
182
|
-
chef_workflow_task 'cookbooks/resolve/librarian'
|
183
|
-
chef_workflow_task 'cookbooks/upload'
|
184
|
-
chef_workflow_task 'chef/roles'
|
185
|
-
chef_workflow_task 'chef/environments'
|
186
|
-
chef_workflow_task 'chef/data_bags'
|
187
|
-
|
188
|
-
task :default => %w[
|
189
|
-
cookbooks:resolve_and_upload
|
190
|
-
chef:roles:upload
|
191
|
-
chef:environments:upload
|
192
|
-
chef:data_bags:upload
|
193
|
-
]
|
194
|
-
```
|
195
|
-
|
196
|
-
Adding new rake tasks (or even full task libs) is easy too with the extensible
|
197
|
-
configuration system and scaffolding already in place, and utility libraries to
|
198
|
-
take the drama out of calling knife plugins or working with collections of
|
199
|
-
machines. Please see the
|
200
|
-
[wiki](https://github.com/chef-workflow/chef-workflow-tasklib/wiki) for more
|
201
|
-
information.
|
202
|
-
|
203
|
-
## Configuring the workflow
|
204
|
-
|
205
|
-
chef-workflow provides you with a number of pre-baked tasks, but say you need
|
206
|
-
just one little tweak so you can get with your life. Maybe it's where the
|
207
|
-
`.chef-workflow` directory lives or where to work with your cookbooks or what
|
208
|
-
vagrant box to use, or whatever. You shouldn't have to rewrite the entire task
|
209
|
-
to change that.
|
210
|
-
|
211
|
-
The `configure_knife` and `configure_vagrant` commands have tooling to assist
|
212
|
-
you with this. If you ran the `chef-workflow-bootstrap` tool, you should have a
|
213
|
-
file called `lib/chef-workflow-config.rb` which is used to store configuration
|
214
|
-
in a central place between this and our testing system.
|
215
|
-
|
216
|
-
Code like this goes in this file:
|
217
|
-
|
218
|
-
```ruby
|
219
|
-
configure_vagrant do
|
220
|
-
# Use this `box_url` for all vagrant machines.
|
221
|
-
box_url "http://files.vagrantup.com/precise64.box"
|
222
|
-
end
|
223
|
-
|
224
|
-
configure_knife do
|
225
|
-
roles_path "our-roles" # set the roles directory for chef:roles:upload
|
226
|
-
end
|
227
|
-
```
|
228
|
-
|
229
|
-
For our custom workflow example above, you can twiddle a few bits with
|
230
|
-
`configure_knife` to point at known chef configuration locations, which can use
|
231
|
-
`~/.chef/knife.rb`, for example. You will want to be careful doing this with
|
232
|
-
test integration.
|
233
|
-
|
234
|
-
`bundle exec rake chef:show_config` can show you most of the settings in a
|
235
|
-
system and how you've configured them.
|
236
|
-
|
237
|
-
Please see the
|
238
|
-
[wiki](https://github.com/chef-workflow/chef-workflow-tasklib/wiki) for more
|
239
|
-
information on how to manipulate this for your own tasks.
|
240
|
-
|
241
|
-
## What's next?
|
242
|
-
|
243
|
-
* Guard support for change-triggered test runs.
|
244
|
-
* Feedback that's more reactive than "everything" or "nothing". The speed (or
|
245
|
-
lack thereof) of running large suites makes this especially tricky.
|
246
|
-
* See the Issues list for more.
|
247
|
-
|
248
|
-
## Problems
|
249
|
-
|
250
|
-
* It's not fast. EC2 support is faster than Vagrant for most complex cases,
|
251
|
-
but it's still pretty slow.
|
252
|
-
* It has two effective noise levels: "a lot" and "silent".
|
253
|
-
|
254
|
-
## Contributing
|
255
|
-
|
256
|
-
1. Fork it
|
257
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
258
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
259
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
260
|
-
5. Create new Pull Request
|
59
|
+
* [HotelTonight](http://www.hoteltonight.com)
|
@@ -5,7 +5,7 @@ require 'chef-workflow-tasklib/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "chef-workflow-tasklib"
|
8
|
-
gem.version =
|
8
|
+
gem.version = ChefWorkflow::Tasklib::VERSION
|
9
9
|
gem.authors = ["Erik Hollensbe"]
|
10
10
|
gem.email = ["erik+github@hollensbe.org"]
|
11
11
|
gem.description = %q{A set of rake tasks provided as discrete libraries for forming a chef workflow}
|
@@ -17,9 +17,8 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency 'chef-workflow'
|
20
|
+
gem.add_dependency 'chef-workflow', '~> 0.2.0'
|
21
21
|
gem.add_dependency 'knife-dsl', '~> 0.1.0'
|
22
22
|
gem.add_dependency 'vagrant-dsl', '~> 0.1.0'
|
23
23
|
gem.add_dependency 'rake', '~> 0.9'
|
24
|
-
gem.add_dependency 'knife-server', '~> 0.3.2'
|
25
24
|
end
|
@@ -1,21 +1,19 @@
|
|
1
1
|
require 'chef-workflow'
|
2
2
|
|
3
|
-
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
require "chef-workflow/tasks/#{obj}"
|
8
|
-
end
|
3
|
+
module ChefWorkflow
|
4
|
+
module TaskHelper
|
5
|
+
def chef_workflow_task(obj)
|
6
|
+
require "chef-workflow/tasks/#{obj}"
|
9
7
|
end
|
10
8
|
end
|
11
9
|
end
|
12
10
|
|
13
11
|
class << eval("self", TOPLEVEL_BINDING)
|
14
|
-
include
|
12
|
+
include ChefWorkflow::TaskHelper
|
15
13
|
end
|
16
14
|
|
17
15
|
if defined? Rake::DSL
|
18
16
|
module Rake::DSL
|
19
|
-
include
|
17
|
+
include ChefWorkflow::TaskHelper
|
20
18
|
end
|
21
19
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'chef-workflow/support/general'
|
2
|
+
require 'chef-workflow/support/ip'
|
3
|
+
require 'chef-workflow/support/vagrant'
|
4
|
+
require 'chef-workflow/support/ec2'
|
5
|
+
require 'chef-workflow/support/knife'
|
6
|
+
require 'chef-workflow/support/scheduler'
|
7
|
+
require 'chef/config'
|
8
|
+
|
9
|
+
if defined? Rake::DSL
|
10
|
+
module Rake::DSL
|
11
|
+
def with_scheduler
|
12
|
+
if File.exist?(ChefWorkflow::KnifeSupport.knife_config_path)
|
13
|
+
Chef::Config.from_file(ChefWorkflow::KnifeSupport.knife_config_path)
|
14
|
+
s = ChefWorkflow::Scheduler.new
|
15
|
+
yield s
|
16
|
+
s.stop
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -3,6 +3,6 @@ require 'chef-workflow/support/knife'
|
|
3
3
|
namespace :bootstrap do
|
4
4
|
task :knife do
|
5
5
|
# this is what knife-dsl needs to know what config to use
|
6
|
-
ENV["CHEF_CONFIG"] ||= KnifeSupport.
|
6
|
+
ENV["CHEF_CONFIG"] ||= ChefWorkflow::KnifeSupport.knife_config_path
|
7
7
|
end
|
8
8
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'chef-workflow/task-helpers/with_scheduler'
|
2
|
+
require 'chef-workflow/support/vm/helpers/knife'
|
3
|
+
|
4
|
+
namespace :chef do
|
5
|
+
desc "build and bootstrap a machine with a role in the run_list"
|
6
|
+
task :build, :role_name, :number_of_machines do |task, args|
|
7
|
+
unless args[:role_name]
|
8
|
+
raise 'You must supply a role name to chef:build'
|
9
|
+
end
|
10
|
+
|
11
|
+
role_name = args[:role_name]
|
12
|
+
number_of_machines = (args[:number_of_machines] || 1).to_i
|
13
|
+
|
14
|
+
with_scheduler do |s|
|
15
|
+
kp = build_knife_provisioner
|
16
|
+
kp.solr_check = false
|
17
|
+
|
18
|
+
s.schedule_provision(
|
19
|
+
role_name,
|
20
|
+
[
|
21
|
+
ChefWorkflow::GeneralSupport.machine_provisioner.new(
|
22
|
+
role_name,
|
23
|
+
number_of_machines
|
24
|
+
),
|
25
|
+
kp
|
26
|
+
],
|
27
|
+
[]
|
28
|
+
)
|
29
|
+
|
30
|
+
s.run
|
31
|
+
s.wait_for(role_name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,42 +1,21 @@
|
|
1
|
-
require 'chef-workflow/
|
2
|
-
require 'chef-workflow/support/ip'
|
3
|
-
require 'chef-workflow/support/vagrant'
|
4
|
-
require 'chef-workflow/support/ec2'
|
5
|
-
require 'chef-workflow/support/knife'
|
6
|
-
require 'chef-workflow/support/scheduler'
|
7
|
-
require 'chef/config'
|
1
|
+
require 'chef-workflow/task-helpers/with_scheduler'
|
8
2
|
require 'fileutils'
|
9
3
|
|
10
4
|
namespace :chef do
|
11
5
|
namespace :clean do
|
12
|
-
desc "Clean up the ip registry for chef-workflow"
|
13
|
-
task :ips do
|
14
|
-
IPSupport.singleton.reset
|
15
|
-
IPSupport.singleton.write
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "Clean up the temporary chef configuration for chef-workflow"
|
19
|
-
task :knife do
|
20
|
-
FileUtils.rm_rf(KnifeSupport.singleton.chef_config_path)
|
21
|
-
FileUtils.rm_f(KnifeSupport.singleton.knife_config_path)
|
22
|
-
end
|
23
|
-
|
24
6
|
desc "Clean up the machines that a previous chef-workflow run generated"
|
25
7
|
task :machines do
|
26
|
-
|
27
|
-
Chef::Config.from_file(KnifeSupport.singleton.knife_config_path)
|
28
|
-
s = Scheduler.new(false)
|
8
|
+
with_scheduler do |s|
|
29
9
|
s.serial = true
|
30
10
|
s.force_deprovision = true
|
31
11
|
s.teardown(%w[chef-server])
|
32
|
-
s.write_state
|
33
12
|
end
|
34
13
|
end
|
35
14
|
end
|
36
15
|
|
37
16
|
desc "Clean up the entire chef-workflow directory and machines"
|
38
17
|
task :clean => [ "chef:clean:machines", "chef_server:destroy" ] do
|
39
|
-
EC2Support.
|
40
|
-
FileUtils.rm_rf(GeneralSupport.
|
18
|
+
ChefWorkflow::EC2Support.destroy_security_group
|
19
|
+
FileUtils.rm_rf(ChefWorkflow::GeneralSupport.workflow_dir)
|
41
20
|
end
|
42
21
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'chef-workflow/task-helpers/ssh'
|
2
|
+
|
3
|
+
namespace :chef do
|
4
|
+
desc "run chef-client on a group of machines"
|
5
|
+
task :converge, :role_name do |task, args|
|
6
|
+
unless args[:role_name]
|
7
|
+
raise "You must supply a node name to converge"
|
8
|
+
end
|
9
|
+
|
10
|
+
ssh_role_command(args[:role_name], 'chef-client')
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'chef-workflow/support/knife'
|
2
|
+
|
3
|
+
ChefWorkflow::KnifeSupport.add_attribute :fc_cookbooks_path, File.join(Dir.pwd, 'cookbooks')
|
4
|
+
ChefWorkflow::KnifeSupport.add_attribute :fc_options, [ ]
|
5
|
+
|
6
|
+
namespace :chef do
|
7
|
+
namespace :cookbooks do
|
8
|
+
desc "Run the cookbooks through foodcritic"
|
9
|
+
task :foodcritic do
|
10
|
+
Rake::Task["chef:cookbooks:resolve"].invoke rescue nil
|
11
|
+
if File.directory?(ChefWorkflow::KnifeSupport.fc_cookbooks_path)
|
12
|
+
Bundler.with_clean_env do
|
13
|
+
sh "foodcritic #{ChefWorkflow::KnifeSupport.fc_cookbooks_path} #{ChefWorkflow::KnifeSupport.fc_options.join(" ")}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
load File.join(File.dirname(__FILE__), '../bootstrap.rb')
|
2
|
+
|
3
|
+
# Both berkshelf and librarian have ... aggressive dependencies. They usually are
|
4
|
+
# a great way to break your Gemfile if you have chef in it.
|
5
|
+
namespace :chef do
|
6
|
+
namespace :cookbooks do
|
7
|
+
desc "Resolve cookbooks and populate using Berkshelf"
|
8
|
+
task :resolve => [ "bootstrap:knife" ] do
|
9
|
+
if File.directory?(KnifeSupport.cookbooks_path)
|
10
|
+
Bundler.with_clean_env do
|
11
|
+
sh "berks install --#{$BERKSHELF_ARG} #{ChefWorkflow::KnifeSupport.cookbooks_path}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Update your locked cookbooks with Berkshelf"
|
17
|
+
task :update => [ "bootstrap:knife" ] do
|
18
|
+
Bundler.with_clean_env do
|
19
|
+
sh "berks update"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
load File.join(File.dirname(__FILE__), 'bootstrap.rb')
|
2
|
+
|
3
|
+
# Both berkshelf and librarian have ... aggressive dependencies. They usually are
|
4
|
+
# a great way to break your Gemfile if you have chef in it.
|
5
|
+
namespace :chef do
|
6
|
+
namespace :cookbooks do
|
7
|
+
desc "Resolve cookbooks and populate using Librarian"
|
8
|
+
task :resolve => [ "bootstrap:knife" ] do
|
9
|
+
if File.directory?(ChefWorkflow::KnifeSupport.cookbooks_path)
|
10
|
+
Bundler.with_clean_env do
|
11
|
+
sh "librarian-chef install --path #{ChefWorkflow::KnifeSupport.cookbooks_path}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Update your locked cookbooks with Librarian"
|
17
|
+
task :update => [ "bootstrap:knife" ] do
|
18
|
+
Bundler.with_clean_env do
|
19
|
+
sh "librarian-chef update"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'knife/dsl'
|
2
|
+
require 'chef-workflow/tasks/bootstrap/knife'
|
3
|
+
|
4
|
+
namespace :chef do
|
5
|
+
namespace :cookbooks do
|
6
|
+
desc "Upload your cookbooks to the chef server"
|
7
|
+
task :upload => [ "bootstrap:knife" ] do
|
8
|
+
Rake::Task["chef:cookbooks:resolve"].invoke rescue nil
|
9
|
+
result = knife %W[cookbook upload -a]
|
10
|
+
fail if result != 0
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -5,7 +5,7 @@ namespace :chef do
|
|
5
5
|
namespace :data_bags do
|
6
6
|
desc "Upload your data bags to the chef server"
|
7
7
|
task :upload => [ "bootstrap:knife" ] do
|
8
|
-
if File.directory?(KnifeSupport.
|
8
|
+
if File.directory?(ChefWorkflow::KnifeSupport.data_bags_path)
|
9
9
|
# bag names: basename of data_bags/*. This presumes your data bags path
|
10
10
|
# is structured like so:
|
11
11
|
#
|
@@ -16,9 +16,15 @@ namespace :chef do
|
|
16
16
|
# directory in the right spots. will probably blow up spectacularly
|
17
17
|
# explode if you deviate heavily from this directory structure.
|
18
18
|
#
|
19
|
-
bag_names = Dir[File.join(KnifeSupport.
|
19
|
+
bag_names = Dir[File.join(ChefWorkflow::KnifeSupport.data_bags_path, "*")].
|
20
20
|
select { |x| File.directory?(x) }.
|
21
|
-
map { |x| File.basename(x) }
|
21
|
+
map { |x| File.basename(x) }
|
22
|
+
|
23
|
+
dbag_from_file = lambda do |bag, items|
|
24
|
+
items = [items] unless items.kind_of?(Array)
|
25
|
+
status = knife %W[data bag from file #{bag}] + items
|
26
|
+
fail if status != 0
|
27
|
+
end
|
22
28
|
|
23
29
|
bag_names.each do |bag|
|
24
30
|
status = knife %W[data bag create #{bag}]
|
@@ -26,10 +32,14 @@ namespace :chef do
|
|
26
32
|
# we're actually depending on this.
|
27
33
|
fail if status != 0
|
28
34
|
|
29
|
-
bag_items = Dir[File.join(KnifeSupport.
|
35
|
+
bag_items = Dir[File.join(ChefWorkflow::KnifeSupport.data_bags_path, bag, '*.{rb,js,json}')].
|
30
36
|
select { |x| !File.directory?(x) }
|
31
|
-
|
32
|
-
|
37
|
+
|
38
|
+
if Chef::VERSION < '10.16'
|
39
|
+
bag_items.each { |item| dbag_from_file.call(bag, item) }
|
40
|
+
else
|
41
|
+
dbag_from_file.call(bag, bag_items)
|
42
|
+
end
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
@@ -5,9 +5,20 @@ namespace :chef do
|
|
5
5
|
namespace :environments do
|
6
6
|
desc "Upload your environments to the chef server"
|
7
7
|
task :upload => [ "bootstrap:knife" ] do
|
8
|
-
if File.directory?(KnifeSupport.
|
9
|
-
|
10
|
-
|
8
|
+
if File.directory?(ChefWorkflow::KnifeSupport.environments_path)
|
9
|
+
env_upload = lambda do |files|
|
10
|
+
files = [files] unless files.kind_of?(Array)
|
11
|
+
status = knife %W[environment from file] + files
|
12
|
+
fail if status != 0
|
13
|
+
end
|
14
|
+
|
15
|
+
environment_files = Dir[File.join(ChefWorkflow::KnifeSupport.environments_path, '*.{rb,js,json}')]
|
16
|
+
|
17
|
+
if Chef::VERSION < '10.16'
|
18
|
+
environment_files.each { |file| env_upload.call(file) }
|
19
|
+
else
|
20
|
+
env_upload.call(environment_files)
|
21
|
+
end
|
11
22
|
end
|
12
23
|
end
|
13
24
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'chef-workflow/task-helpers/with_scheduler'
|
2
|
+
require 'chef-workflow/support/ip'
|
3
|
+
require 'chef-workflow/support/general'
|
4
|
+
require 'chef-workflow/support/ip'
|
5
|
+
require 'chef-workflow/support/knife'
|
6
|
+
require 'chef-workflow/support/vagrant'
|
7
|
+
|
8
|
+
namespace :chef do
|
9
|
+
namespace :info do
|
10
|
+
desc "Output some information about provisioned machines"
|
11
|
+
task :provisioned do
|
12
|
+
with_scheduler do |s|
|
13
|
+
s.vm_groups.each do |key, values|
|
14
|
+
puts "Group: #{key}"
|
15
|
+
values.each do |value|
|
16
|
+
puts "\t#{value.class.name} provisioner:"
|
17
|
+
value.name ||= key
|
18
|
+
value.report.each do |line|
|
19
|
+
puts "\t\t#{line}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Output some information about known IP allocations"
|
27
|
+
task :ips do
|
28
|
+
ChefWorkflow::IPSupport.roles.each do |role|
|
29
|
+
puts "Group: #{role}"
|
30
|
+
ChefWorkflow::IPSupport.get_role_ips(role).each do |ip|
|
31
|
+
puts "\t#{ip}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Show the calculated configuration for chef-workflow"
|
37
|
+
task :config do
|
38
|
+
puts "general:"
|
39
|
+
puts "\tworkflow_dir: #{ChefWorkflow::GeneralSupport.workflow_dir}"
|
40
|
+
puts "\tvm_file: #{ChefWorkflow::GeneralSupport.vm_file}"
|
41
|
+
puts "\tmachine_provisoner: #{ChefWorkflow::GeneralSupport.machine_provisioner}"
|
42
|
+
|
43
|
+
puts "knife:"
|
44
|
+
mute = %w[knife_config_template]
|
45
|
+
ChefWorkflow::KnifeSupport::DEFAULTS.keys.reject { |x| mute.include?(x.to_s) }.each do |key|
|
46
|
+
puts "\t#{key}: #{ChefWorkflow::KnifeSupport.send(key)}"
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "vagrant:"
|
50
|
+
puts "\tip subnet (/24): #{ChefWorkflow::IPSupport.subnet}"
|
51
|
+
puts "\tbox url: #{ChefWorkflow::VagrantSupport.box_url}"
|
52
|
+
|
53
|
+
puts "ec2:"
|
54
|
+
|
55
|
+
%w[
|
56
|
+
ami
|
57
|
+
instance_type
|
58
|
+
region
|
59
|
+
ssh_key
|
60
|
+
security_groups
|
61
|
+
security_group_open_ports
|
62
|
+
].each do |key|
|
63
|
+
puts "\t#{key}: #{ChefWorkflow::EC2Support.send(key)}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -5,8 +5,8 @@ namespace :chef do
|
|
5
5
|
namespace :roles do
|
6
6
|
desc "Upload your roles to the chef server"
|
7
7
|
task :upload => [ "bootstrap:knife" ] do
|
8
|
-
if File.directory?(KnifeSupport.
|
9
|
-
status = knife %W[role from file] + Dir[File.join(KnifeSupport.
|
8
|
+
if File.directory?(ChefWorkflow::KnifeSupport.roles_path)
|
9
|
+
status = knife %W[role from file] + Dir[File.join(ChefWorkflow::KnifeSupport.roles_path, '*.{rb,js,json}')]
|
10
10
|
fail if status != 0
|
11
11
|
end
|
12
12
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
chef_workflow_task 'chef/data_bags'
|
2
2
|
chef_workflow_task 'chef/environments'
|
3
3
|
chef_workflow_task 'chef/roles'
|
4
|
-
chef_workflow_task 'cookbooks/upload'
|
4
|
+
chef_workflow_task 'chef/cookbooks/upload'
|
5
5
|
|
6
6
|
namespace :chef do
|
7
7
|
desc "Upload everything."
|
8
8
|
task :upload => %w[
|
9
|
-
cookbooks:upload
|
9
|
+
chef:cookbooks:upload
|
10
10
|
chef:roles:upload
|
11
11
|
chef:environments:upload
|
12
12
|
chef:data_bags:upload
|
@@ -1,41 +1,42 @@
|
|
1
|
-
require 'chef-workflow/
|
2
|
-
require 'chef-workflow/support/knife'
|
3
|
-
require 'chef-workflow/support/scheduler'
|
1
|
+
require 'chef-workflow/task-helpers/with_scheduler'
|
4
2
|
|
5
3
|
namespace :chef_server do
|
6
|
-
desc "Create a chef server with the #{GeneralSupport.
|
7
|
-
task :create do
|
4
|
+
desc "Create a chef server with the #{ChefWorkflow::GeneralSupport.machine_provisioner} provisioner"
|
5
|
+
task :create => [ "chef:clean" ] do
|
6
|
+
chef_workflow_task 'bootstrap/db'
|
7
|
+
Rake::Task["bootstrap:db"].invoke
|
8
|
+
|
8
9
|
# FIXME not really happy with having to repeat this at the end, but it's
|
9
10
|
# necessary. maybe a subroutine in the right place in the future is the
|
10
11
|
# best approach, but I'm feeling lazy right now.
|
11
|
-
KnifeSupport.
|
12
|
-
Chef::Config.from_file(KnifeSupport.singleton.knife_config_path)
|
13
|
-
|
14
|
-
s = Scheduler.new(false)
|
15
|
-
s.serial = true
|
12
|
+
ChefWorkflow::KnifeSupport.build_knife_config
|
16
13
|
|
17
|
-
s
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
with_scheduler do |s|
|
15
|
+
s.serial = true
|
16
|
+
s.schedule_provision(
|
17
|
+
'chef-server',
|
18
|
+
[
|
19
|
+
ChefWorkflow::GeneralSupport.machine_provisioner.new('chef-server', 1),
|
20
|
+
ChefWorkflow::VM::ChefServerProvisioner.new
|
21
|
+
],
|
22
|
+
[]
|
23
|
+
)
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
s.run
|
26
|
+
s.wait_for('chef-server') # probably superfluous
|
27
|
+
end
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
# now that our chef server exists, re-bootstrap the config for future tasks
|
30
|
+
ChefWorkflow::KnifeSupport.build_knife_config
|
31
|
+
Chef::Config.from_file(ChefWorkflow::KnifeSupport.knife_config_path)
|
32
32
|
end
|
33
33
|
|
34
34
|
desc "Destroy the chef server"
|
35
35
|
task :destroy do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
with_scheduler do |s|
|
37
|
+
s.serial = true
|
38
|
+
s.force_deprovision = true
|
39
|
+
s.teardown_group('chef-server')
|
40
|
+
end
|
40
41
|
end
|
41
42
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
chef_workflow_task 'chef_server'
|
2
|
-
chef_workflow_task 'cookbooks/upload'
|
2
|
+
chef_workflow_task 'chef/cookbooks/upload'
|
3
3
|
chef_workflow_task 'chef/upload'
|
4
|
-
chef_workflow_task 'chef/show_config'
|
5
4
|
chef_workflow_task 'chef/clean'
|
5
|
+
chef_workflow_task 'chef/build'
|
6
|
+
chef_workflow_task 'chef/converge'
|
7
|
+
chef_workflow_task 'chef/info'
|
6
8
|
chef_workflow_task 'test/build'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rake/testtask'
|
2
|
-
require 'chef-workflow/
|
3
|
-
require 'chef-workflow/support/knife'
|
2
|
+
require 'chef-workflow/task-helpers/with_scheduler'
|
3
|
+
require 'chef-workflow/support/vm/helpers/knife'
|
4
4
|
|
5
5
|
Rake::TestTask.new do |t|
|
6
6
|
t.libs << "test"
|
@@ -11,59 +11,49 @@ end
|
|
11
11
|
namespace :test do
|
12
12
|
desc "Test recipes in the test_recipes configuration."
|
13
13
|
|
14
|
-
task :recipes => [ "recipes:cleanup" ] do
|
15
|
-
|
16
|
-
|
17
|
-
s = Scheduler.new(true)
|
18
|
-
s.run
|
14
|
+
task :recipes => [ "test:recipes:cleanup" ] do
|
15
|
+
with_scheduler do |s|
|
16
|
+
s.run
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
groups =
|
19
|
+
ChefWorkflow::KnifeSupport.test_recipes.map do |recipe|
|
20
|
+
group_name = "recipe-#{recipe.gsub(/::/, '-')}"
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
kp.use_sudo = KnifeSupport.singleton.use_sudo
|
28
|
-
kp.ssh_key = KnifeSupport.singleton.ssh_identity_file
|
29
|
-
kp.environment = KnifeSupport.singleton.test_environment
|
30
|
-
kp.run_list = [ "recipe[#{recipe}]", "recipe[minitest-handler]" ]
|
31
|
-
kp.solr_check = false
|
22
|
+
kp = build_knife_provisioner
|
23
|
+
kp.run_list = [ "recipe[#{recipe}]", "recipe[minitest-handler]" ]
|
24
|
+
kp.solr_check = false
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
26
|
+
s.schedule_provision(
|
27
|
+
group_name,
|
28
|
+
[
|
29
|
+
ChefWorkflow::GeneralSupport.machine_provisioner.new(group_name, 1),
|
30
|
+
kp
|
31
|
+
]
|
32
|
+
)
|
40
33
|
|
41
|
-
|
42
|
-
|
34
|
+
group_name
|
35
|
+
end
|
43
36
|
|
44
|
-
|
37
|
+
s.wait_for(*groups)
|
45
38
|
|
46
|
-
|
47
|
-
|
39
|
+
groups.each do |group_name|
|
40
|
+
s.teardown_group(group_name)
|
41
|
+
end
|
48
42
|
end
|
49
|
-
|
50
|
-
s.write_state
|
51
43
|
end
|
52
44
|
|
53
45
|
namespace :recipes do
|
54
46
|
desc "Cleanup any stale instances created running recipe tests."
|
55
47
|
task :cleanup do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
g
|
62
|
-
|
63
|
-
|
48
|
+
with_scheduler do |s|
|
49
|
+
s.run
|
50
|
+
|
51
|
+
s.vm_groups.select do |g, v|
|
52
|
+
g.start_with?("recipe-")
|
53
|
+
end.each do |g, v|
|
54
|
+
s.teardown_group(g, false)
|
55
|
+
end
|
64
56
|
end
|
65
|
-
|
66
|
-
s.write_state
|
67
57
|
end
|
68
58
|
end
|
69
59
|
end
|
@@ -3,22 +3,9 @@ require 'chef-workflow/tasks/chef/upload'
|
|
3
3
|
require 'chef-workflow/tasks/chef/clean'
|
4
4
|
|
5
5
|
namespace :test do
|
6
|
-
|
7
|
-
begin
|
8
|
-
Rake::Task["cookbooks:resolve"].invoke
|
9
|
-
rescue
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
desc "Refresh all global meta on the chef server"
|
14
|
-
task :refresh => [
|
15
|
-
"test:resolve_hack",
|
16
|
-
"chef:upload"
|
17
|
-
]
|
18
|
-
|
19
|
-
desc "test:refresh and test"
|
6
|
+
desc "chef:upload and test"
|
20
7
|
task :build => [
|
21
|
-
"
|
8
|
+
"chef:upload",
|
22
9
|
"test"
|
23
10
|
]
|
24
11
|
|
@@ -32,6 +19,10 @@ namespace :test do
|
|
32
19
|
task :full => [
|
33
20
|
"chef_server:create",
|
34
21
|
"test:build",
|
35
|
-
"
|
36
|
-
]
|
22
|
+
"test:recipes"
|
23
|
+
] do
|
24
|
+
# hack to get chef:clean to run again
|
25
|
+
(Rake::Task["chef:clean"].prerequisite_tasks + [Rake::Task["chef:clean"]]).each(&:reenable)
|
26
|
+
Rake::Task["chef:clean"].invoke
|
27
|
+
end
|
37
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-workflow-tasklib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef-workflow
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 0.2.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: knife-dsl
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,22 +75,6 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0.9'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: knife-server
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 0.3.2
|
86
|
-
type: :runtime
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 0.3.2
|
94
78
|
description: A set of rake tasks provided as discrete libraries for forming a chef
|
95
79
|
workflow
|
96
80
|
email:
|
@@ -100,6 +84,7 @@ extensions: []
|
|
100
84
|
extra_rdoc_files: []
|
101
85
|
files:
|
102
86
|
- .gitignore
|
87
|
+
- CHANGELOG.md
|
103
88
|
- Gemfile
|
104
89
|
- LICENSE.txt
|
105
90
|
- README.md
|
@@ -107,22 +92,26 @@ files:
|
|
107
92
|
- chef-workflow-tasklib.gemspec
|
108
93
|
- lib/chef-workflow-tasklib.rb
|
109
94
|
- lib/chef-workflow-tasklib/version.rb
|
95
|
+
- lib/chef-workflow/task-helpers/ssh.rb
|
96
|
+
- lib/chef-workflow/task-helpers/with_scheduler.rb
|
97
|
+
- lib/chef-workflow/tasks/bootstrap/db.rb
|
110
98
|
- lib/chef-workflow/tasks/bootstrap/knife.rb
|
99
|
+
- lib/chef-workflow/tasks/chef/build.rb
|
111
100
|
- lib/chef-workflow/tasks/chef/clean.rb
|
101
|
+
- lib/chef-workflow/tasks/chef/converge.rb
|
102
|
+
- lib/chef-workflow/tasks/chef/cookbooks/foodcritic.rb
|
103
|
+
- lib/chef-workflow/tasks/chef/cookbooks/resolve/berkshelf.rb
|
104
|
+
- lib/chef-workflow/tasks/chef/cookbooks/resolve/berkshelf/berkshelf-base.rb
|
105
|
+
- lib/chef-workflow/tasks/chef/cookbooks/resolve/berkshelf0.4.rb
|
106
|
+
- lib/chef-workflow/tasks/chef/cookbooks/resolve/bootstrap.rb
|
107
|
+
- lib/chef-workflow/tasks/chef/cookbooks/resolve/librarian.rb
|
108
|
+
- lib/chef-workflow/tasks/chef/cookbooks/upload.rb
|
112
109
|
- lib/chef-workflow/tasks/chef/data_bags.rb
|
113
110
|
- lib/chef-workflow/tasks/chef/environments.rb
|
111
|
+
- lib/chef-workflow/tasks/chef/info.rb
|
114
112
|
- lib/chef-workflow/tasks/chef/roles.rb
|
115
|
-
- lib/chef-workflow/tasks/chef/show_config.rb
|
116
113
|
- lib/chef-workflow/tasks/chef/upload.rb
|
117
114
|
- lib/chef-workflow/tasks/chef_server.rb
|
118
|
-
- lib/chef-workflow/tasks/cookbooks/foodcritic.rb
|
119
|
-
- lib/chef-workflow/tasks/cookbooks/resolve/berkshelf.rb
|
120
|
-
- lib/chef-workflow/tasks/cookbooks/resolve/berkshelf/berkshelf-base.rb
|
121
|
-
- lib/chef-workflow/tasks/cookbooks/resolve/berkshelf0.4.rb
|
122
|
-
- lib/chef-workflow/tasks/cookbooks/resolve/bootstrap.rb
|
123
|
-
- lib/chef-workflow/tasks/cookbooks/resolve/librarian.rb
|
124
|
-
- lib/chef-workflow/tasks/cookbooks/resolve_and_upload.rb
|
125
|
-
- lib/chef-workflow/tasks/cookbooks/upload.rb
|
126
115
|
- lib/chef-workflow/tasks/default.rb
|
127
116
|
- lib/chef-workflow/tasks/test.rb
|
128
117
|
- lib/chef-workflow/tasks/test/build.rb
|
@@ -146,9 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
135
|
version: '0'
|
147
136
|
requirements: []
|
148
137
|
rubyforge_project:
|
149
|
-
rubygems_version: 1.8.
|
138
|
+
rubygems_version: 1.8.25
|
150
139
|
signing_key:
|
151
140
|
specification_version: 3
|
152
141
|
summary: A set of rake tasks provided as discrete libraries for forming a chef workflow
|
153
142
|
test_files: []
|
154
|
-
has_rdoc:
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'chef-workflow/support/general'
|
2
|
-
require 'chef-workflow/support/ip'
|
3
|
-
require 'chef-workflow/support/knife'
|
4
|
-
require 'chef-workflow/support/vagrant'
|
5
|
-
|
6
|
-
namespace :chef do
|
7
|
-
desc "Show the calculated configuration for chef-workflow"
|
8
|
-
task :show_config do
|
9
|
-
puts "general:"
|
10
|
-
puts "\tworkflow_dir: #{GeneralSupport.singleton.workflow_dir}"
|
11
|
-
puts "\tvm_file: #{GeneralSupport.singleton.vm_file}"
|
12
|
-
puts "\tchef_server_prison: #{GeneralSupport.singleton.chef_server_prison}"
|
13
|
-
puts "\tmachine_provisoner: #{GeneralSupport.singleton.machine_provisioner}"
|
14
|
-
|
15
|
-
puts "knife:"
|
16
|
-
mute = %w[knife_config_template]
|
17
|
-
KnifeSupport::DEFAULTS.keys.reject { |x| mute.include?(x.to_s) }.each do |key|
|
18
|
-
puts "\t#{key}: #{KnifeSupport.singleton.send(key)}"
|
19
|
-
end
|
20
|
-
|
21
|
-
puts "vagrant:"
|
22
|
-
puts "\tip subnet (/24): #{IPSupport.singleton.subnet}"
|
23
|
-
puts "\tbox url: #{VagrantSupport.singleton.box_url}"
|
24
|
-
|
25
|
-
puts "ec2:"
|
26
|
-
|
27
|
-
%w[
|
28
|
-
ami
|
29
|
-
instance_type
|
30
|
-
region
|
31
|
-
ssh_key
|
32
|
-
security_groups
|
33
|
-
security_group_open_ports
|
34
|
-
].each do |key|
|
35
|
-
puts "\t#{key}: #{EC2Support.singleton.send(key)}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'chef-workflow/support/knife'
|
2
|
-
|
3
|
-
KnifeSupport.add_attribute :fc_cookbooks_path, File.join(Dir.pwd, 'cookbooks')
|
4
|
-
KnifeSupport.add_attribute :fc_options, [ ]
|
5
|
-
|
6
|
-
namespace :cookbooks do
|
7
|
-
desc "Run the cookbooks through foodcritic"
|
8
|
-
task :foodcritic do
|
9
|
-
Rake::Task["cookbooks:resolve"].invoke rescue nil
|
10
|
-
if File.directory?(KnifeSupport.singleton.fc_cookbooks_path)
|
11
|
-
Bundler.with_clean_env do
|
12
|
-
sh "foodcritic #{KnifeSupport.singleton.fc_cookbooks_path} #{KnifeSupport.singleton.fc_options.join(" ")}"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
load File.join(File.dirname(__FILE__), '../bootstrap.rb')
|
2
|
-
|
3
|
-
# Both berkshelf and librarian have ... aggressive dependencies. They usually are
|
4
|
-
# a great way to break your Gemfile if you have chef in it.
|
5
|
-
namespace :cookbooks do
|
6
|
-
desc "Resolve cookbooks and populate using Berkshelf"
|
7
|
-
task :resolve => [ "bootstrap:knife" ] do
|
8
|
-
if File.directory?(KnifeSupport.singleton.cookbooks_path)
|
9
|
-
Bundler.with_clean_env do
|
10
|
-
sh "berks install --#{$BERKSHELF_ARG} #{KnifeSupport.singleton.cookbooks_path}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "Update your locked cookbooks with Berkshelf"
|
16
|
-
task :update => [ "bootstrap:knife" ] do
|
17
|
-
Bundler.with_clean_env do
|
18
|
-
sh "berks update"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# used by resolver tasklibs to ensure their basic dependencies are met. Not to
|
2
|
-
# be used directly.
|
3
|
-
begin
|
4
|
-
Rake::Task["cookbooks:resolve"].clear
|
5
|
-
Rake::Task["cookbooks:update"].clear
|
6
|
-
rescue
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'chef-workflow/tasks/bootstrap/knife'
|
10
|
-
require 'chef-workflow/tasks/cookbooks/resolve_and_upload'
|
@@ -1,21 +0,0 @@
|
|
1
|
-
load File.join(File.dirname(__FILE__), 'bootstrap.rb')
|
2
|
-
|
3
|
-
# Both berkshelf and librarian have ... aggressive dependencies. They usually are
|
4
|
-
# a great way to break your Gemfile if you have chef in it.
|
5
|
-
namespace :cookbooks do
|
6
|
-
desc "Resolve cookbooks and populate using Librarian"
|
7
|
-
task :resolve => [ "bootstrap:knife" ] do
|
8
|
-
if File.directory?(KnifeSupport.singleton.cookbooks_path)
|
9
|
-
Bundler.with_clean_env do
|
10
|
-
sh "librarian-chef install --path #{KnifeSupport.singleton.cookbooks_path}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "Update your locked cookbooks with Librarian"
|
16
|
-
task :update => [ "bootstrap:knife" ] do
|
17
|
-
Bundler.with_clean_env do
|
18
|
-
sh "librarian-chef update"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'knife/dsl'
|
2
|
-
require 'chef-workflow/tasks/bootstrap/knife'
|
3
|
-
|
4
|
-
namespace :cookbooks do
|
5
|
-
desc "Upload your cookbooks to the chef server"
|
6
|
-
task :upload => [ "bootstrap:knife" ] do
|
7
|
-
result = knife %W[cookbook upload -a]
|
8
|
-
fail if result != 0
|
9
|
-
end
|
10
|
-
end
|