chef-metal 0.14.2 → 0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +2 -257
- data/Rakefile +0 -4
- data/lib/chef_metal.rb +1 -87
- data/lib/chef_metal/action_handler.rb +1 -66
- data/lib/chef_metal/add_prefix_action_handler.rb +1 -29
- data/lib/chef_metal/chef_image_spec.rb +1 -106
- data/lib/chef_metal/chef_machine_spec.rb +1 -82
- data/lib/chef_metal/chef_provider_action_handler.rb +1 -72
- data/lib/chef_metal/chef_run_data.rb +1 -125
- data/lib/chef_metal/convergence_strategy.rb +1 -26
- data/lib/chef_metal/convergence_strategy/install_cached.rb +1 -157
- data/lib/chef_metal/convergence_strategy/install_msi.rb +1 -56
- data/lib/chef_metal/convergence_strategy/install_sh.rb +1 -53
- data/lib/chef_metal/convergence_strategy/no_converge.rb +1 -37
- data/lib/chef_metal/convergence_strategy/precreate_chef_objects.rb +1 -181
- data/lib/chef_metal/driver.rb +1 -288
- data/lib/chef_metal/image_spec.rb +1 -70
- data/lib/chef_metal/machine.rb +1 -110
- data/lib/chef_metal/machine/basic_machine.rb +1 -82
- data/lib/chef_metal/machine/unix_machine.rb +1 -276
- data/lib/chef_metal/machine/windows_machine.rb +1 -102
- data/lib/chef_metal/machine_spec.rb +1 -78
- data/lib/chef_metal/recipe_dsl.rb +1 -94
- data/lib/chef_metal/transport.rb +1 -87
- data/lib/chef_metal/transport/ssh.rb +1 -288
- data/lib/chef_metal/transport/winrm.rb +1 -134
- data/lib/chef_metal/version.rb +1 -3
- metadata +19 -145
- data/bin/metal +0 -275
- data/lib/chef/provider/machine.rb +0 -171
- data/lib/chef/provider/machine_batch.rb +0 -186
- data/lib/chef/provider/machine_execute.rb +0 -30
- data/lib/chef/provider/machine_file.rb +0 -49
- data/lib/chef/provider/machine_image.rb +0 -54
- data/lib/chef/resource/machine.rb +0 -116
- data/lib/chef/resource/machine_batch.rb +0 -72
- data/lib/chef/resource/machine_execute.rb +0 -22
- data/lib/chef/resource/machine_file.rb +0 -28
- data/lib/chef/resource/machine_image.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f221c28948b41a195d4361334eb08a0fa9d8dd2
|
4
|
+
data.tar.gz: b93820c3fb7e4d855c4a77de770ca85de9bc567d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbd80f5ce21ea1fade973624fa8aee45cc7ad657d3ac15e410570bf62ad37e3e4b684be0978ddbe3e007b2ecd38ae916c04c781027fe0e925f217a02d3affc78
|
7
|
+
data.tar.gz: 98ff89fc7405ee116144e8cb3aa3bddf2d8ab6fd7f2968af4603196d7f57dd2efdf893473d1ec8c31b092bf1064d296a7df80b95784d9ec361733b9983660bf5
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Chef Metal Changelog
|
2
2
|
|
3
|
+
## 0.15 (9/28/2014)
|
4
|
+
|
5
|
+
- Rename chef-metal to chef-provisioning
|
6
|
+
|
3
7
|
## 0.14.2 (9/2/2014)
|
4
8
|
|
5
9
|
- Disable auto batching
|
6
|
-
- Fix for with_machine_options context hash
|
10
|
+
- Fix for with_machine_options context hash
|
7
11
|
- Pass timeout from execution_options to winrm set_timeout
|
8
12
|
- Add better error message when driver does not specify driver_url
|
9
13
|
- Add info that location.driver_url is required
|
data/README.md
CHANGED
@@ -1,258 +1,3 @@
|
|
1
|
-
|
2
|
-
Chef Metal
|
3
|
-
==========
|
1
|
+
This gem exists to provide a backwards-compatible link to `chef-provisioning`.
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
[This video](https://www.youtube.com/watch?v=Yb8QdL30WgM) explains the basics of chef-metal (though provisioners are now called drivers). Slides (more up to date) are [here](http://slides.com/jkeiser/chef-metal).
|
8
|
-
|
9
|
-
Date | Blog
|
10
|
-
-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
11
|
-
6/3/2014 | [machine_batch and parallelization](https://github.com/opscode/chef-metal/blob/master/docs/blogs/2012-05-28-machine_batch.html.markdown#chef-metal-parallelization)
|
12
|
-
6/3/2014 | [Chef Metal, Configuration and Drivers](https://github.com/opscode/chef-metal/blob/master/docs/blogs/2012-05-22-new-driver-interface.html.markdown#chef-metal-configuration-and-drivers)
|
13
|
-
3/4/2014 | [Chef Metal 0.2: Overview](http://www.getchef.com/blog/2014/03/04/chef-metal-0-2-release/) - this is a pretty good overview (though dated).
|
14
|
-
12/20/2013 | [Chef Metal Alpha](http://www.getchef.com/blog/2013/12/20/chef-metal-alpha/)
|
15
|
-
|
16
|
-
Documentation
|
17
|
-
-------------
|
18
|
-
* [Configuration](https://github.com/opscode/chef-metal/blob/master/docs/configuration.md#configuring-and-using-metal-drivers)
|
19
|
-
* [Writing Drivers](https://github.com/opscode/chef-metal/blob/master/docs/building_drivers.md#writing-drivers)
|
20
|
-
* [Embedding](https://github.com/opscode/chef-metal/blob/master/docs/embedding.md)
|
21
|
-
* [Providers](https://github.com/opscode/chef-metal/blob/master/docs/providers)
|
22
|
-
|
23
|
-
Try It Out
|
24
|
-
----------
|
25
|
-
|
26
|
-
You can try out Metal in many different flavors.
|
27
|
-
|
28
|
-
### Vagrant
|
29
|
-
|
30
|
-
To give it a spin, install Vagrant and VirtualBox and try this from the `chef-metal/docs/examples` directory:
|
31
|
-
|
32
|
-
```
|
33
|
-
gem install chef-metal chef-metal-vagrant
|
34
|
-
export CHEF_DRIVER=vagrant
|
35
|
-
chef-client -z vagrant_linux.rb simple.rb
|
36
|
-
```
|
37
|
-
|
38
|
-
This will create two vagrant precise64 linux boxes, "mario" and "luigi1", in `~/machinetest`, bootstrapped to an empty runlist. For Windows, you can replace `myapp::linux` with `myapp::windows`, but you'll need your own Windows vagrant box to do that (licensing!).
|
39
|
-
|
40
|
-
### AWS
|
41
|
-
|
42
|
-
If you have an AWS account, you can spin up a machine there like this:
|
43
|
-
|
44
|
-
```
|
45
|
-
gem install chef-metal chef-metal-fog
|
46
|
-
export CHEF_DRIVER=fog:AWS
|
47
|
-
chef-client -z simple.rb
|
48
|
-
```
|
49
|
-
|
50
|
-
This will create two linux boxes in the AWS account referenced by your default profile in `~/.aws/config` (or your environment variables).
|
51
|
-
|
52
|
-
### DigitalOcean
|
53
|
-
|
54
|
-
If you are on DigitalOcean and using the `tugboat` gem, you can do this:
|
55
|
-
|
56
|
-
```
|
57
|
-
gem install chef-metal chef-metal-fog
|
58
|
-
export CHEF_DRIVER=fog:DigitalOcean
|
59
|
-
chef-client -z simple.rb
|
60
|
-
```
|
61
|
-
|
62
|
-
If you aren't using the `tugboat` gem, you can put `driver` and `driver_options` into your `.chef/knife.rb` file.
|
63
|
-
|
64
|
-
This will use your tugboat settings to create whatever sort of instance you normally create.
|
65
|
-
|
66
|
-
### Cleaning up
|
67
|
-
|
68
|
-
When you are done with the examples, run this to clean up:
|
69
|
-
|
70
|
-
```
|
71
|
-
chef-client -z destroy_all.rb
|
72
|
-
```
|
73
|
-
|
74
|
-
What Is Chef Metal?
|
75
|
-
-------------------
|
76
|
-
|
77
|
-
Chef Metal has two major abstractions: the machine resource, and drivers.
|
78
|
-
|
79
|
-
### The `machine` resource
|
80
|
-
|
81
|
-
You declare what your machines do (recipes, tags, etc.) with the `machine` resource, the fundamental unit of Chef Metal. You will typically declare `machine` resources in a separate, OS/provisioning-independent file that declares the *topology* of your app--your machines and the recipes that will run on them.
|
82
|
-
|
83
|
-
The machine resources from the example [myapp::small](https://github.com/opscode/chef-metal/blob/master/cookbooks/myapp/recipes/small.rb) are pretty straightforward. Here's a copy/paste:
|
84
|
-
|
85
|
-
```ruby
|
86
|
-
machine 'mario' do
|
87
|
-
recipe 'postgresql'
|
88
|
-
recipe 'mydb'
|
89
|
-
tag 'mydb_master'
|
90
|
-
end
|
91
|
-
|
92
|
-
num_webservers = 1
|
93
|
-
|
94
|
-
1.upto(num_webservers) do |i|
|
95
|
-
machine "luigi#{i}" do
|
96
|
-
recipe 'apache'
|
97
|
-
recipe 'mywebapp'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
```
|
101
|
-
|
102
|
-
You will notice the dynamic nature of the number of web servers. It's all code, your imagination is the limit :)
|
103
|
-
|
104
|
-
### Drivers
|
105
|
-
|
106
|
-
Drivers handle the real work of getting those abstract definitions into real, physical form. They handle the following tasks, idempotently (you can run the resource again and again and it will only create the machine once--though it may notice things are wrong and fix them!):
|
107
|
-
|
108
|
-
* Acquiring machines from the cloud, creating containers or VMs, or grabbing bare metal
|
109
|
-
* Connecting to those machines via ssh, winrm, or other transports
|
110
|
-
* Bootstrapping chef onto the machines and converging the recipes you suggested
|
111
|
-
|
112
|
-
The driver API is separated out so that new drivers can be made with minimal effort (without having to rewrite ssh, tunneling, bootstrapping, and OS support). But to the user, they appear as a single thing, so that the machine acquisition can use its smarts to autodetect the other bits (transports, OS's, etc.).
|
113
|
-
|
114
|
-
Drivers save their data in the Chef node itself, so that they will be accessible to everyone who is using the Chef server to manage the nodes.
|
115
|
-
|
116
|
-
Drivers each have their own repository. Current drivers:
|
117
|
-
|
118
|
-
**Cloud:**
|
119
|
-
- [FOG: EC2, DigitalOcean, OpenStack, etc.](https://github.com/opscode/chef-metal-fog)
|
120
|
-
|
121
|
-
**Virtualization:**
|
122
|
-
- [Vagrant: VirtualBox, VMWare Fusion, etc.](https://github.com/opscode/chef-metal-vagrant)
|
123
|
-
- [VSphere](https://github.com/RallySoftware-cookbooks/chef-metal-vsphere) (not yet up to date with 0.11)
|
124
|
-
|
125
|
-
**Containers:**
|
126
|
-
- [LXC](https://github.com/opscode/chef-metal-lxc) (not yet up to date with 0.11)
|
127
|
-
- [Docker](https://github.com/opscode/chef-metal-docker) (not yet up to date with 0.11)
|
128
|
-
|
129
|
-
**Bare Metal:**
|
130
|
-
- [SSH (no PXE)](https://github.com/double-z/chef-metal-ssh) (not yet up to date with 0.11)
|
131
|
-
|
132
|
-
### Anatomy of a Recipe
|
133
|
-
|
134
|
-
chef-zero comes with a provisioner for Vagrant, an abstraction that covers VirtualBox, VMWare and other Virtual Machine drivers. In docs/examples, you can run this to try it:
|
135
|
-
|
136
|
-
```ruby
|
137
|
-
export CHEF_DRIVER=vagrant
|
138
|
-
chef-client -z vagrant_linux.rb simple.rb
|
139
|
-
```
|
140
|
-
|
141
|
-
This is a chef-client run, which runs multiple **recipes.** Chef Metal is nothing but resources you put in recipes.
|
142
|
-
|
143
|
-
The driver is specified on the command line. Drivers are URLs. You could use `vagrant:~/vms` or `fog:AWS:default:us-east-1' as driver URLs. More information [here.](https://github.com/opscode/chef-metal/blob/master/docs/configuration.md#setting-the-driver-with-a-driver-url)
|
144
|
-
|
145
|
-
The `vagrant_linux.rb` recipe handles the physical specification of the machines and Vagrant box:
|
146
|
-
|
147
|
-
```ruby
|
148
|
-
require 'chef_metal_vagrant'
|
149
|
-
|
150
|
-
vagrant_box 'precise64' do
|
151
|
-
url 'http://files.vagrantup.com/precise64.box'
|
152
|
-
end
|
153
|
-
|
154
|
-
with_machine_options :vagrant_options => {
|
155
|
-
'vm.box' => 'precise64'
|
156
|
-
}
|
157
|
-
```
|
158
|
-
|
159
|
-
`require 'chef_metal_vagrant'` is how we bring in the `vagrant_box` resource.
|
160
|
-
|
161
|
-
`vagrant_box` makes sure a particular vagrant box exists, and lets you specify `machine_options` for things like port forwarding, OS definitions, and any other vagrant-isms.
|
162
|
-
|
163
|
-
Typically, you declare these in separate files from your machine resources. Chef Metal picks up the drivers and machine_options you have declared, and uses them to instantiate the machines you request. The actual machine definitions, in this case, are in `simple.rb`, and are generic--you could use them against Azure or EC2 as well:
|
164
|
-
|
165
|
-
```ruby
|
166
|
-
machine 'mario' do
|
167
|
-
tag 'itsame'
|
168
|
-
end
|
169
|
-
```
|
170
|
-
|
171
|
-
Other directives, like `recipe 'apache'`, help you set run lists and other information about the machine.
|
172
|
-
|
173
|
-
### Fog (EC2, Openstack and friends)
|
174
|
-
|
175
|
-
chef-metal also comes with a [Fog](http://fog.io/) provisioner that handles provisioning to Openstack, Rackspace, Amazon's EC2 and other cloud drivers. Before you begin, you will need to put your AWS credentials in ~/.aws/config in the format [mentioned in Option 1 here](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#d0e726). There are other ways to specify your credentials, but this is the standard one for the Amazon CLI.
|
176
|
-
|
177
|
-
Once your credentials are in, basic usage looks like this:
|
178
|
-
|
179
|
-
```
|
180
|
-
export CHEF_DRIVER=fog:AWS
|
181
|
-
chef-client -z simple.rb
|
182
|
-
```
|
183
|
-
|
184
|
-
Other valid URLs include `fog:AWS:myprofilename` and `fog:AWS:profilename:us-west-2`.
|
185
|
-
|
186
|
-
Most Chef Metal drivers try hard to provide reasonable defaults so you can get started easily. Once you have specified your credentials, AMIs and other things are chosen for you.
|
187
|
-
|
188
|
-
You will usually want to create or input a custom key pair for bootstrap. To customize, specify keys and AMI and other options, you can make recipes like this:
|
189
|
-
|
190
|
-
```ruby
|
191
|
-
require 'chef_metal_fog'
|
192
|
-
|
193
|
-
fog_key_pair 'my_bootstrap_key'
|
194
|
-
|
195
|
-
with_machine_options :bootstrap_options => {
|
196
|
-
:key_name => 'my_bootstrap_key',
|
197
|
-
:image_id => 'ami-59a4a230',
|
198
|
-
:flavor_id => 't1.micro'
|
199
|
-
}
|
200
|
-
```
|
201
|
-
|
202
|
-
`fog_key_pair` creates a new key pair (if the files do not already exist) and uploads it to AWS (it will toss an error if the key pair already exists and does not match). By default, `fog_key_pair` will look for matching key files in .chef/keys, ~/.chef/keys and ~/.ssh. If it does not find one, it will place the key in `.chef/keys`. You can override this path in fog_key_pair, but if you do, you will want to modify `private_key_paths` in your configuration to match.
|
203
|
-
|
204
|
-
`with_machine_options` specifies machine_options that will be applied to any `machine` resources chef-client encounters.
|
205
|
-
|
206
|
-
You will notice that we are still using `simple.rb` here. Machine definitions are generally driver-independent. This is an important feature that allows you to spin up your clusters in different places to create staging, test or miniature dev environments.
|
207
|
-
|
208
|
-
### Pointing Boxes at Chef Servers
|
209
|
-
|
210
|
-
By default, Chef Metal will put your boxes on the same Chef server you started chef-client with (in the case of -z, that's a local chef-zero server). Sometimes you want to put your boxes on different servers. There are a couple of ways to do that:
|
211
|
-
|
212
|
-
```ruby
|
213
|
-
with_chef_local_server :chef_repo_path => '~/repo'
|
214
|
-
```
|
215
|
-
|
216
|
-
`with_chef_local_server` is a generic directive that creates a chef-zero server pointed at the given repository. nodes, clients, data bags, and all data will be stored here on your provisioner machine if you do this.
|
217
|
-
|
218
|
-
You can use `with_chef_server` instead if you want to point at OSS, Hosted or Enterprise Chef, and if you don't specify a Chef server at all, it will use the one you are running chef-client against. Keep in mind when using `with_chef_server` and running `chef-client -z` on your workstation that you will also need to set the client name and signing key for the chef server. If you've already got knife.rb set up, then something like this will correctly create a client for the chef server on instance using your knife.rb configuration:
|
219
|
-
|
220
|
-
```ruby
|
221
|
-
with_chef_server "https://chef-server.example.org",
|
222
|
-
:client_name => Chef::Config[:node_name],
|
223
|
-
:signing_key_filename => Chef::Config[:client_key]
|
224
|
-
```
|
225
|
-
|
226
|
-
**Note for Hosted/Enterprise Chef Servers**
|
227
|
-
|
228
|
-
Currently, you will need to add the 'clients' group to the 'admin' group in order for machine provisioning to work:
|
229
|
-
|
230
|
-
```
|
231
|
-
knife edit /groups/admin.json -e <editor>
|
232
|
-
```
|
233
|
-
Then add:
|
234
|
-
```
|
235
|
-
{
|
236
|
-
"users": [
|
237
|
-
"pivotal" # This is an internal superuser for Hosted/Enterprise Chef
|
238
|
-
],
|
239
|
-
"groups": [
|
240
|
-
"clients" # This is what you need to add
|
241
|
-
]
|
242
|
-
}
|
243
|
-
```
|
244
|
-
|
245
|
-
This can also be done through the Chef Server web UI (Administration tab > Groups > select admins Group > Add 'clients'
|
246
|
-
|
247
|
-
|
248
|
-
Kitchen
|
249
|
-
-------
|
250
|
-
|
251
|
-
Chef Metal also works with Test Kitchen, allowing you to test entire clusters, not just machines! The repository for the kitchen-metal gem is https://github.com/doubt72/kitchen-metal.
|
252
|
-
|
253
|
-
Bugs and The Plan
|
254
|
-
-----------------
|
255
|
-
|
256
|
-
Please submit bugs, gripes and feature requests at [https://github.com/opscode/chef-metal/issues](https://twitter.com/jkeiser2), contact jkeiser on Twitter at @jkeiser2, email at [jkeiser@getchef.com](mailto:jkeiser@getchef.com)
|
257
|
-
|
258
|
-
To contribute, just make a PR in the appropriate repo--also, make sure you've [signed the Chef Contributor License Agreement](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L) (quick couple of minutes online), since this is going into core Chef eventually. It takes some time to process, so if you've just done it, let me know in the PR :) If you already signed this for a Chef contribution, you don't need to do so again--if you're not sure, you can check for your name [here](https://wiki.opscode.com/display/chef/Approved+Contributors)!
|
3
|
+
Please load `https://github.com/opscode/chef-provisioning` now.
|
data/Rakefile
CHANGED
data/lib/chef_metal.rb
CHANGED
@@ -1,87 +1 @@
|
|
1
|
-
|
2
|
-
require 'chef_metal/recipe_dsl'
|
3
|
-
require 'chef/server_api'
|
4
|
-
require 'cheffish/basic_chef_client'
|
5
|
-
require 'cheffish/merged_config'
|
6
|
-
|
7
|
-
module ChefMetal
|
8
|
-
def self.inline_resource(action_handler, &block)
|
9
|
-
events = ActionHandlerForward.new(action_handler)
|
10
|
-
Cheffish::BasicChefClient.converge_block(nil, events, &block)
|
11
|
-
end
|
12
|
-
|
13
|
-
class ActionHandlerForward < Chef::EventDispatch::Base
|
14
|
-
def initialize(action_handler)
|
15
|
-
@action_handler = action_handler
|
16
|
-
end
|
17
|
-
|
18
|
-
attr_reader :action_handler
|
19
|
-
|
20
|
-
def resource_update_applied(resource, action, update)
|
21
|
-
prefix = action_handler.should_perform_actions ? "" : "Would "
|
22
|
-
update = Array(update).flatten.map { |u| "#{prefix}#{u}"}
|
23
|
-
action_handler.performed_action(update)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Helpers for driver inflation
|
28
|
-
@@registered_driver_classes = {}
|
29
|
-
def self.register_driver_class(name, driver)
|
30
|
-
@@registered_driver_classes[name] = driver
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.default_driver(config = Cheffish.profiled_config)
|
34
|
-
driver_for_url(config[:driver], config)
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.driver_for_url(driver_url, config = Cheffish.profiled_config, allow_different_config = false)
|
38
|
-
#
|
39
|
-
# Create and cache the driver
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# Figure out the driver class
|
43
|
-
#
|
44
|
-
scheme = driver_url.split(':', 2)[0]
|
45
|
-
require "chef_metal/driver_init/#{scheme}"
|
46
|
-
driver_class = @@registered_driver_classes[scheme]
|
47
|
-
|
48
|
-
#
|
49
|
-
# Merge in any driver-specific config
|
50
|
-
#
|
51
|
-
if config[:drivers] && config[:drivers][driver_url]
|
52
|
-
config = Cheffish::MergedConfig.new(config[:drivers][driver_url], config)
|
53
|
-
end
|
54
|
-
|
55
|
-
#
|
56
|
-
# Canonicalize the URL
|
57
|
-
#
|
58
|
-
canonicalized_url, canonicalized_config = driver_class.canonicalize_url(driver_url, config)
|
59
|
-
config = canonicalized_config if canonicalized_config
|
60
|
-
|
61
|
-
#
|
62
|
-
# Merge in config from the canonicalized URL if it is different
|
63
|
-
#
|
64
|
-
if canonicalized_url != driver_url
|
65
|
-
if config[:drivers] && config[:drivers][canonicalized_url]
|
66
|
-
config = Cheffish::MergedConfig.new(config[:drivers][canonicalized_url], config)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
driver_class.from_url(canonicalized_url, config)
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.connect_to_machine(machine_spec, config = Cheffish.profiled_config)
|
74
|
-
chef_server = Cheffish.default_chef_server(config)
|
75
|
-
if machine_spec.is_a?(String)
|
76
|
-
machine_spec = ChefMachineSpec.get(machine_spec, chef_server)
|
77
|
-
end
|
78
|
-
driver = driver_for_url(machine_spec.driver_url, config)
|
79
|
-
if driver
|
80
|
-
machine_options = { :convergence_options => { :chef_server => chef_server } }
|
81
|
-
machine_options = Cheffish::MergedConfig.new(config[:machine_options], machine_options) if config[:machine_options]
|
82
|
-
driver.connect_to_machine(machine_spec, machine_options)
|
83
|
-
else
|
84
|
-
nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
1
|
+
require 'chef/provisioning'
|
@@ -1,66 +1 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author:: Douglas Triggs (<doug@getchef.com>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2014, Chef, Inc.
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
# This is the generic action handler
|
20
|
-
module ChefMetal
|
21
|
-
class ActionHandler
|
22
|
-
|
23
|
-
# This should be replaced with whatever records the update; by default it
|
24
|
-
# essentially does nothing here.
|
25
|
-
def updated!
|
26
|
-
@updated = true
|
27
|
-
end
|
28
|
-
|
29
|
-
def should_perform_actions
|
30
|
-
true
|
31
|
-
end
|
32
|
-
|
33
|
-
def report_progress(description)
|
34
|
-
Array(description).each { |d| puts d }
|
35
|
-
end
|
36
|
-
|
37
|
-
def performed_action(description)
|
38
|
-
Array(description).each { |d| puts d }
|
39
|
-
end
|
40
|
-
|
41
|
-
# This should perform the actual action (e.g., converge) if there is an
|
42
|
-
# action that needs to be done.
|
43
|
-
def perform_action(description)
|
44
|
-
if should_perform_actions
|
45
|
-
result = yield
|
46
|
-
else
|
47
|
-
result = nil
|
48
|
-
end
|
49
|
-
performed_action(description)
|
50
|
-
result
|
51
|
-
end
|
52
|
-
|
53
|
-
# Open a stream which can be printed to and closed
|
54
|
-
def open_stream(name)
|
55
|
-
if block_given?
|
56
|
-
yield STDOUT
|
57
|
-
else
|
58
|
-
STDOUT
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# A URL identifying the host node. nil if no such node.
|
63
|
-
def host_node
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
1
|
+
require "chef/provisioning/action_handler"
|