chef-provisioning 0.19 → 0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +62 -32
- data/lib/chef/provider/load_balancer.rb +18 -8
- data/lib/chef/provider/machine.rb +11 -7
- data/lib/chef/provider/machine_batch.rb +8 -4
- data/lib/chef/provider/machine_execute.rb +1 -1
- data/lib/chef/provider/machine_image.rb +46 -14
- data/lib/chef/provisioning.rb +9 -1
- data/lib/chef/provisioning/chef_managed_entry_store.rb +128 -0
- data/lib/chef/provisioning/chef_run_data.rb +9 -16
- data/lib/chef/provisioning/convergence_strategy/install_cached.rb +25 -7
- data/lib/chef/provisioning/convergence_strategy/install_msi.rb +26 -8
- data/lib/chef/provisioning/convergence_strategy/install_sh.rb +28 -6
- data/lib/chef/provisioning/driver.rb +28 -21
- data/lib/chef/provisioning/load_balancer_spec.rb +6 -71
- data/lib/chef/provisioning/machine_image_spec.rb +34 -0
- data/lib/chef/provisioning/machine_spec.rb +23 -47
- data/lib/chef/provisioning/managed_entry.rb +121 -0
- data/lib/chef/provisioning/managed_entry_store.rb +136 -0
- data/lib/chef/provisioning/recipe_dsl.rb +0 -4
- data/lib/chef/provisioning/version.rb +1 -1
- data/lib/chef/resource/chef_data_bag_resource.rb +1 -2
- data/lib/chef/resource/load_balancer.rb +1 -0
- data/lib/chef/resource/machine.rb +1 -1
- data/lib/chef/resource/machine_batch.rb +2 -2
- data/lib/chef/resource/machine_execute.rb +2 -1
- metadata +7 -8
- data/lib/chef/provisioning/chef_image_spec.rb +0 -111
- data/lib/chef/provisioning/chef_load_balancer_spec.rb +0 -108
- data/lib/chef/provisioning/chef_machine_spec.rb +0 -83
- data/lib/chef/provisioning/image_spec.rb +0 -72
@@ -19,10 +19,6 @@ class Chef
|
|
19
19
|
module DSL
|
20
20
|
module Recipe
|
21
21
|
|
22
|
-
def with_data_center(data_center, &block)
|
23
|
-
run_context.chef_metal.with_data_center(data_center, &block)
|
24
|
-
end
|
25
|
-
|
26
22
|
def with_driver(driver, options = nil, &block)
|
27
23
|
run_context.chef_provisioning.with_driver(driver, options, &block)
|
28
24
|
end
|
@@ -10,8 +10,6 @@ class Chef::Resource::ChefDataBagResource < Chef::Resource::LWRPBase
|
|
10
10
|
class << self
|
11
11
|
# The name of the databag to store the item in.
|
12
12
|
attr_reader :databag_name
|
13
|
-
# A list of attributes to be persisted into the databag.
|
14
|
-
attr_reader :stored_attributes
|
15
13
|
end
|
16
14
|
|
17
15
|
def initialize(name, run_context=nil)
|
@@ -20,6 +18,7 @@ class Chef::Resource::ChefDataBagResource < Chef::Resource::LWRPBase
|
|
20
18
|
self.hydrate
|
21
19
|
end
|
22
20
|
|
21
|
+
# A list of attributes to be persisted into the databag.
|
23
22
|
# @return [Array] List of attributes that are stored in the databag
|
24
23
|
def self.stored_attributes
|
25
24
|
@stored_attributes || []
|
@@ -48,7 +48,7 @@ class Machine < Chef::Resource::LWRPBase
|
|
48
48
|
attribute :validator, :kind_of => [TrueClass, FalseClass]
|
49
49
|
|
50
50
|
# Client Ohai hints, allows machine to enable hints
|
51
|
-
# e.g.
|
51
|
+
# e.g. ohai_hints 'ec2' => { 'a' => 'b' } creates file ec2.json with json contents { 'a': 'b' }
|
52
52
|
attribute :ohai_hints, :kind_of => Hash
|
53
53
|
|
54
54
|
# A string containing extra configuration for the machine
|
@@ -22,7 +22,7 @@ class MachineBatch < Chef::Resource::LWRPBase
|
|
22
22
|
attribute :max_simultaneous, :kind_of => [ Integer ]
|
23
23
|
attribute :from_recipe
|
24
24
|
|
25
|
-
# These four attributes are for when you pass names or
|
25
|
+
# These four attributes are for when you pass names or ManagedEntrys to
|
26
26
|
# "machines". Not used for auto-batch or explicit inline machine declarations.
|
27
27
|
attribute :driver
|
28
28
|
attribute :chef_server
|
@@ -58,7 +58,7 @@ class MachineBatch < Chef::Resource::LWRPBase
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
machine_names = @machines.map do |m|
|
61
|
-
if m.is_a?(Chef::Provisioning::
|
61
|
+
if m.is_a?(Chef::Provisioning::ManagedEntry)
|
62
62
|
m.name
|
63
63
|
elsif m.is_a?(Chef::Resource::Machine)
|
64
64
|
m.name
|
@@ -19,10 +19,11 @@ class MachineExecute < Chef::Resource::LWRPBase
|
|
19
19
|
|
20
20
|
attribute :command, :kind_of => String, :name_attribute => true
|
21
21
|
attribute :machine, :kind_of => String
|
22
|
+
attribute :live_stream, :kind_of => [TrueClass,FalseClass], :default => false
|
22
23
|
|
23
24
|
attribute :chef_server, :kind_of => Hash
|
24
25
|
attribute :driver, :kind_of => Chef::Provisioning::Driver
|
25
26
|
|
26
27
|
end
|
27
28
|
end
|
28
|
-
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.20'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -144,9 +144,7 @@ files:
|
|
144
144
|
- lib/chef/provisioning.rb
|
145
145
|
- lib/chef/provisioning/action_handler.rb
|
146
146
|
- lib/chef/provisioning/add_prefix_action_handler.rb
|
147
|
-
- lib/chef/provisioning/
|
148
|
-
- lib/chef/provisioning/chef_load_balancer_spec.rb
|
149
|
-
- lib/chef/provisioning/chef_machine_spec.rb
|
147
|
+
- lib/chef/provisioning/chef_managed_entry_store.rb
|
150
148
|
- lib/chef/provisioning/chef_provider_action_handler.rb
|
151
149
|
- lib/chef/provisioning/chef_run_data.rb
|
152
150
|
- lib/chef/provisioning/convergence_strategy.rb
|
@@ -156,13 +154,15 @@ files:
|
|
156
154
|
- lib/chef/provisioning/convergence_strategy/no_converge.rb
|
157
155
|
- lib/chef/provisioning/convergence_strategy/precreate_chef_objects.rb
|
158
156
|
- lib/chef/provisioning/driver.rb
|
159
|
-
- lib/chef/provisioning/image_spec.rb
|
160
157
|
- lib/chef/provisioning/load_balancer_spec.rb
|
161
158
|
- lib/chef/provisioning/machine.rb
|
162
159
|
- lib/chef/provisioning/machine/basic_machine.rb
|
163
160
|
- lib/chef/provisioning/machine/unix_machine.rb
|
164
161
|
- lib/chef/provisioning/machine/windows_machine.rb
|
162
|
+
- lib/chef/provisioning/machine_image_spec.rb
|
165
163
|
- lib/chef/provisioning/machine_spec.rb
|
164
|
+
- lib/chef/provisioning/managed_entry.rb
|
165
|
+
- lib/chef/provisioning/managed_entry_store.rb
|
166
166
|
- lib/chef/provisioning/recipe_dsl.rb
|
167
167
|
- lib/chef/provisioning/transport.rb
|
168
168
|
- lib/chef/provisioning/transport/ssh.rb
|
@@ -195,9 +195,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
version: '0'
|
196
196
|
requirements: []
|
197
197
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.4.2
|
199
199
|
signing_key:
|
200
200
|
specification_version: 4
|
201
201
|
summary: A library for creating machines and infrastructures idempotently in Chef.
|
202
202
|
test_files: []
|
203
|
-
has_rdoc:
|
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'chef/provisioning'
|
2
|
-
require 'cheffish'
|
3
|
-
require 'chef/provisioning/image_spec'
|
4
|
-
|
5
|
-
class Chef
|
6
|
-
module Provisioning
|
7
|
-
#
|
8
|
-
# Specification for a image. Sufficient information to find and contact it
|
9
|
-
# after it has been set up.
|
10
|
-
#
|
11
|
-
class ChefImageSpec < ImageSpec
|
12
|
-
def initialize(node, chef_server)
|
13
|
-
super(node)
|
14
|
-
@chef_server = chef_server
|
15
|
-
end
|
16
|
-
|
17
|
-
#
|
18
|
-
# Get a ImageSpec from the chef server. If the image does not exist on the
|
19
|
-
# server, it returns nil.
|
20
|
-
#
|
21
|
-
def self.get(name, chef_server = Cheffish.default_chef_server)
|
22
|
-
chef_api = Cheffish.chef_server_api(chef_server)
|
23
|
-
begin
|
24
|
-
data = chef_api.get("/data/images/#{name}")
|
25
|
-
data['machine_options'] = strings_to_symbols(data['machine_options'])
|
26
|
-
ChefImageSpec.new(data, chef_server)
|
27
|
-
rescue Net::HTTPServerException => e
|
28
|
-
if e.response.code == '404'
|
29
|
-
nil
|
30
|
-
else
|
31
|
-
raise
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Creates a new empty ImageSpec with the given name.
|
37
|
-
def self.empty(id, chef_server = Cheffish.default_chef_server)
|
38
|
-
ChefImageSpec.new({ 'id' => id }, chef_server)
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# Globally unique identifier for this image. Does not depend on the image's
|
43
|
-
# location or existence.
|
44
|
-
#
|
45
|
-
def id
|
46
|
-
ChefImageSpec.id_from(chef_server, name)
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.id_from(chef_server, name)
|
50
|
-
"#{chef_server[:chef_server_url]}/data/images/#{name}"
|
51
|
-
end
|
52
|
-
|
53
|
-
#
|
54
|
-
# Save this image to the server. If you have significant information that
|
55
|
-
# could be lost, you should do this as quickly as possible. Data will be
|
56
|
-
# saved automatically for you after allocate_image and ready_image.
|
57
|
-
#
|
58
|
-
def save(action_handler)
|
59
|
-
# Save the image to the server.
|
60
|
-
_self = self
|
61
|
-
_chef_server = _self.chef_server
|
62
|
-
Chef::Provisioning.inline_resource(action_handler) do
|
63
|
-
# Create the data bag if needed
|
64
|
-
chef_data_bag 'images'
|
65
|
-
# Save the image
|
66
|
-
chef_data_bag_item _self.name do
|
67
|
-
data_bag 'images'
|
68
|
-
chef_server _chef_server
|
69
|
-
raw_data _self.image_data
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def delete(action_handler)
|
75
|
-
# Delete the image from the server.
|
76
|
-
_self = self
|
77
|
-
_chef_server = _self.chef_server
|
78
|
-
Chef::Provisioning.inline_resource(action_handler) do
|
79
|
-
chef_data_bag_item _self.name do
|
80
|
-
data_bag 'images'
|
81
|
-
chef_server _chef_server
|
82
|
-
action :delete
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
protected
|
88
|
-
|
89
|
-
attr_reader :chef_server
|
90
|
-
|
91
|
-
#
|
92
|
-
# Chef API object for the given Chef server
|
93
|
-
#
|
94
|
-
def chef_api
|
95
|
-
Cheffish.server_api_for(chef_server)
|
96
|
-
end
|
97
|
-
|
98
|
-
def self.strings_to_symbols(data)
|
99
|
-
if data.is_a?(Hash)
|
100
|
-
result = {}
|
101
|
-
data.each_pair do |key, value|
|
102
|
-
result[key.to_sym] = strings_to_symbols(value)
|
103
|
-
end
|
104
|
-
result
|
105
|
-
else
|
106
|
-
data
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'chef/provisioning'
|
2
|
-
require 'cheffish'
|
3
|
-
require 'chef/provisioning/load_balancer_spec'
|
4
|
-
|
5
|
-
class Chef
|
6
|
-
module Provisioning
|
7
|
-
#
|
8
|
-
# Specification for a image. Sufficient information to find and contact it
|
9
|
-
# after it has been set up.
|
10
|
-
#
|
11
|
-
class ChefLoadBalancerSpec < LoadBalancerSpec
|
12
|
-
def initialize(node, chef_server)
|
13
|
-
super(node)
|
14
|
-
@chef_server = chef_server
|
15
|
-
end
|
16
|
-
|
17
|
-
#
|
18
|
-
# Get a ImageSpec from the chef server. If the node does not exist on the
|
19
|
-
# server, it returns nil.
|
20
|
-
#
|
21
|
-
def self.get(name, chef_server = Cheffish.default_chef_server)
|
22
|
-
chef_api = Cheffish.chef_server_api(chef_server)
|
23
|
-
begin
|
24
|
-
data = chef_api.get("/data/loadbalancers/#{name}")
|
25
|
-
ChefLoadBalancerSpec.new(data, chef_server)
|
26
|
-
rescue Net::HTTPServerException => e
|
27
|
-
if e.response.code == '404'
|
28
|
-
nil
|
29
|
-
else
|
30
|
-
raise
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Creates a new empty ImageSpec with the given name.
|
36
|
-
def self.empty(id, chef_server = Cheffish.default_chef_server)
|
37
|
-
ChefLoadBalancerSpec.new({ 'id' => id }, chef_server)
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# Globally unique identifier for this image. Does not depend on the image's
|
42
|
-
# location or existence.
|
43
|
-
#
|
44
|
-
def id
|
45
|
-
ChefLoadBalancerSpec.id_from(chef_server, name)
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.id_from(chef_server, name)
|
49
|
-
"#{chef_server[:chef_server_url]}/data/loadbalancers/#{name}"
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# Save this node to the server. If you have significant information that
|
54
|
-
# could be lost, you should do this as quickly as possible. Data will be
|
55
|
-
# saved automatically for you after allocate_image and ready_image.
|
56
|
-
#
|
57
|
-
def save(action_handler)
|
58
|
-
# Save the node to the server.
|
59
|
-
_self = self
|
60
|
-
_chef_server = _self.chef_server
|
61
|
-
Chef::Provisioning.inline_resource(action_handler) do
|
62
|
-
chef_data_bag 'loadbalancers'
|
63
|
-
chef_data_bag_item _self.name do
|
64
|
-
data_bag 'loadbalancers'
|
65
|
-
chef_server _chef_server
|
66
|
-
raw_data _self.load_balancer_data
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def delete(action_handler)
|
72
|
-
# Save the node to the server.
|
73
|
-
_self = self
|
74
|
-
_chef_server = _self.chef_server
|
75
|
-
Chef::Provisioning.inline_resource(action_handler) do
|
76
|
-
chef_data_bag_item _self.name do
|
77
|
-
data_bag 'loadbalancers'
|
78
|
-
chef_server _chef_server
|
79
|
-
action :delete
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
protected
|
85
|
-
|
86
|
-
attr_reader :chef_server
|
87
|
-
|
88
|
-
#
|
89
|
-
# Chef API object for the given Chef server
|
90
|
-
#
|
91
|
-
def chef_api
|
92
|
-
Cheffish.server_api_for(chef_server)
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.strings_to_symbols(data)
|
96
|
-
if data.is_a?(Hash)
|
97
|
-
result = {}
|
98
|
-
data.each_pair do |key, value|
|
99
|
-
result[key.to_sym] = strings_to_symbols(value)
|
100
|
-
end
|
101
|
-
result
|
102
|
-
else
|
103
|
-
data
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'chef/provisioning'
|
2
|
-
require 'cheffish'
|
3
|
-
require 'chef/provisioning/machine_spec'
|
4
|
-
|
5
|
-
class Chef
|
6
|
-
module Provisioning
|
7
|
-
#
|
8
|
-
# Specification for a machine. Sufficient information to find and contact it
|
9
|
-
# after it has been set up.
|
10
|
-
#
|
11
|
-
class ChefMachineSpec < MachineSpec
|
12
|
-
def initialize(node, chef_server)
|
13
|
-
super(node)
|
14
|
-
@chef_server = chef_server
|
15
|
-
end
|
16
|
-
|
17
|
-
#
|
18
|
-
# Get a MachineSpec from the chef server. If the node does not exist on the
|
19
|
-
# server, it returns nil.
|
20
|
-
#
|
21
|
-
def self.get(name, chef_server = Cheffish.default_chef_server)
|
22
|
-
chef_api = Cheffish.chef_server_api(chef_server)
|
23
|
-
begin
|
24
|
-
ChefMachineSpec.new(chef_api.get("/nodes/#{name}"), chef_server)
|
25
|
-
rescue Net::HTTPServerException => e
|
26
|
-
if e.response.code == '404'
|
27
|
-
nil
|
28
|
-
else
|
29
|
-
raise
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Creates a new empty MachineSpec with the given name.
|
35
|
-
def self.empty(name, chef_server = Cheffish.default_chef_server)
|
36
|
-
ChefMachineSpec.new({ 'name' => name, 'normal' => {} }, chef_server)
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# Globally unique identifier for this machine. Does not depend on the machine's
|
41
|
-
# location or existence.
|
42
|
-
#
|
43
|
-
def id
|
44
|
-
ChefMachineSpec.id_from(chef_server, name)
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.id_from(chef_server, name)
|
48
|
-
"#{chef_server[:chef_server_url]}/nodes/#{name}"
|
49
|
-
end
|
50
|
-
|
51
|
-
#
|
52
|
-
# Save this node to the server. If you have significant information that
|
53
|
-
# could be lost, you should do this as quickly as possible. Data will be
|
54
|
-
# saved automatically for you after allocate_machine and ready_machine.
|
55
|
-
#
|
56
|
-
def save(action_handler)
|
57
|
-
if location && (!location.is_a?(Hash) || !location['driver_url'])
|
58
|
-
raise "Drivers must specify a canonical driver_url in machine_spec.location. Contact your driver's author."
|
59
|
-
end
|
60
|
-
# Save the node to the server.
|
61
|
-
_self = self
|
62
|
-
_chef_server = _self.chef_server
|
63
|
-
Chef::Provisioning.inline_resource(action_handler) do
|
64
|
-
chef_node _self.name do
|
65
|
-
chef_server _chef_server
|
66
|
-
raw_json _self.node
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
protected
|
72
|
-
|
73
|
-
attr_reader :chef_server
|
74
|
-
|
75
|
-
#
|
76
|
-
# Chef API object for the given Chef server
|
77
|
-
#
|
78
|
-
def chef_api
|
79
|
-
Cheffish.server_api_for(chef_server)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|