chef-provisioning 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +906 -899
  3. data/Gemfile +17 -17
  4. data/LICENSE +201 -201
  5. data/README.md +312 -312
  6. data/Rakefile +55 -55
  7. data/chef-provisioning.gemspec +38 -38
  8. data/lib/chef/provider/load_balancer.rb +75 -75
  9. data/lib/chef/provider/machine.rb +219 -219
  10. data/lib/chef/provider/machine_batch.rb +224 -224
  11. data/lib/chef/provider/machine_execute.rb +36 -36
  12. data/lib/chef/provider/machine_file.rb +55 -55
  13. data/lib/chef/provider/machine_image.rb +105 -105
  14. data/lib/chef/provisioning.rb +110 -110
  15. data/lib/chef/provisioning/action_handler.rb +68 -68
  16. data/lib/chef/provisioning/add_prefix_action_handler.rb +35 -35
  17. data/lib/chef/provisioning/chef_managed_entry_store.rb +128 -128
  18. data/lib/chef/provisioning/chef_provider_action_handler.rb +74 -74
  19. data/lib/chef/provisioning/chef_run_data.rb +132 -132
  20. data/lib/chef/provisioning/convergence_strategy.rb +28 -28
  21. data/lib/chef/provisioning/convergence_strategy/ignore_convergence_failure.rb +54 -54
  22. data/lib/chef/provisioning/convergence_strategy/install_cached.rb +188 -188
  23. data/lib/chef/provisioning/convergence_strategy/install_msi.rb +71 -71
  24. data/lib/chef/provisioning/convergence_strategy/install_sh.rb +71 -71
  25. data/lib/chef/provisioning/convergence_strategy/no_converge.rb +35 -35
  26. data/lib/chef/provisioning/convergence_strategy/precreate_chef_objects.rb +255 -255
  27. data/lib/chef/provisioning/driver.rb +323 -323
  28. data/lib/chef/provisioning/load_balancer_spec.rb +14 -14
  29. data/lib/chef/provisioning/machine.rb +112 -112
  30. data/lib/chef/provisioning/machine/basic_machine.rb +84 -84
  31. data/lib/chef/provisioning/machine/unix_machine.rb +288 -288
  32. data/lib/chef/provisioning/machine/windows_machine.rb +108 -108
  33. data/lib/chef/provisioning/machine_image_spec.rb +34 -34
  34. data/lib/chef/provisioning/machine_spec.rb +58 -58
  35. data/lib/chef/provisioning/managed_entry.rb +121 -121
  36. data/lib/chef/provisioning/managed_entry_store.rb +136 -136
  37. data/lib/chef/provisioning/recipe_dsl.rb +99 -99
  38. data/lib/chef/provisioning/rspec.rb +27 -27
  39. data/lib/chef/provisioning/transport.rb +100 -100
  40. data/lib/chef/provisioning/transport/ssh.rb +403 -403
  41. data/lib/chef/provisioning/transport/winrm.rb +144 -144
  42. data/lib/chef/provisioning/version.rb +5 -5
  43. data/lib/chef/resource/chef_data_bag_resource.rb +146 -146
  44. data/lib/chef/resource/load_balancer.rb +57 -57
  45. data/lib/chef/resource/machine.rb +128 -128
  46. data/lib/chef/resource/machine_batch.rb +78 -78
  47. data/lib/chef/resource/machine_execute.rb +30 -30
  48. data/lib/chef/resource/machine_file.rb +34 -34
  49. data/lib/chef/resource/machine_image.rb +35 -35
  50. data/lib/chef_metal.rb +1 -1
  51. data/spec/chef/provisioning/convergence_strategy/ignore_convergence_failure_spec.rb +86 -86
  52. data/spec/spec_helper.rb +27 -27
  53. metadata +10 -4
@@ -1,74 +1,74 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Douglas Triggs (<doug@chef.io>)
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
- require 'chef/provisioning/action_handler'
20
-
21
- # This is included in provisioning drivers to proxy from generic requests needed
22
- # to specific driver actions
23
- class Chef
24
- module Provisioning
25
- class ChefProviderActionHandler < ActionHandler
26
- def initialize(provider)
27
- @provider = provider
28
- end
29
-
30
- attr_reader :provider
31
-
32
- def updated!
33
- provider.new_resource.updated_by_last_action(true)
34
- end
35
-
36
- def should_perform_actions
37
- !provider.run_context.config.why_run
38
- end
39
-
40
- def report_progress(description)
41
- # TODO this seems wrong but Chef doesn't have another thing
42
- provider.converge_by description do
43
- # We already did the action, but we trust whoever told us that they did it.
44
- end
45
- end
46
-
47
- def performed_action(description)
48
- provider.converge_by description do
49
- # We already did the action, but we trust whoever told us that they did it.
50
- end
51
- end
52
-
53
- def perform_action(description, &block)
54
- provider.converge_by(description, &block)
55
- end
56
-
57
- def open_stream(name, &block)
58
- if provider.run_context.respond_to?(:open_stream)
59
- provider.run_context.open_stream({ :name => name }, &block)
60
- else
61
- if block_given?
62
- yield STDOUT
63
- else
64
- STDOUT
65
- end
66
- end
67
- end
68
-
69
- def host_node
70
- "#{provider.run_context.config[:chef_server_url]}/nodes/#{provider.run_context.node['name']}"
71
- end
72
- end
73
- end
74
- end
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Douglas Triggs (<doug@chef.io>)
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
+ require 'chef/provisioning/action_handler'
20
+
21
+ # This is included in provisioning drivers to proxy from generic requests needed
22
+ # to specific driver actions
23
+ class Chef
24
+ module Provisioning
25
+ class ChefProviderActionHandler < ActionHandler
26
+ def initialize(provider)
27
+ @provider = provider
28
+ end
29
+
30
+ attr_reader :provider
31
+
32
+ def updated!
33
+ provider.new_resource.updated_by_last_action(true)
34
+ end
35
+
36
+ def should_perform_actions
37
+ !provider.run_context.config.why_run
38
+ end
39
+
40
+ def report_progress(description)
41
+ # TODO this seems wrong but Chef doesn't have another thing
42
+ provider.converge_by description do
43
+ # We already did the action, but we trust whoever told us that they did it.
44
+ end
45
+ end
46
+
47
+ def performed_action(description)
48
+ provider.converge_by description do
49
+ # We already did the action, but we trust whoever told us that they did it.
50
+ end
51
+ end
52
+
53
+ def perform_action(description, &block)
54
+ provider.converge_by(description, &block)
55
+ end
56
+
57
+ def open_stream(name, &block)
58
+ if provider.run_context.respond_to?(:open_stream)
59
+ provider.run_context.open_stream({ :name => name }, &block)
60
+ else
61
+ if block_given?
62
+ yield STDOUT
63
+ else
64
+ STDOUT
65
+ end
66
+ end
67
+ end
68
+
69
+ def host_node
70
+ "#{provider.run_context.config[:chef_server_url]}/nodes/#{provider.run_context.node['name']}"
71
+ end
72
+ end
73
+ end
74
+ end
@@ -1,132 +1,132 @@
1
- require 'chef/mixin/deep_merge'
2
- require 'cheffish/merged_config'
3
-
4
- class Chef
5
- module Provisioning
6
- class ChefRunData
7
-
8
- def initialize(config)
9
- @config = config
10
- @drivers = {}
11
- end
12
-
13
- attr_reader :config
14
- attr_reader :drivers
15
- attr_reader :current_driver
16
- attr_accessor :current_machine_options
17
- attr_accessor :current_load_balancer_options
18
- attr_accessor :current_image_options
19
-
20
- def with_machine_options(value)
21
- old_value = self.current_machine_options
22
- self.current_machine_options = value
23
- if block_given?
24
- begin
25
- yield
26
- ensure
27
- self.current_machine_options = old_value
28
- end
29
- end
30
- end
31
-
32
- def with_image_options(value)
33
- old_value = self.current_image_options
34
- self.current_image_options = value
35
- if block_given?
36
- begin
37
- yield
38
- ensure
39
- self.current_image_options = old_value
40
- end
41
- end
42
- end
43
-
44
- def with_driver(driver, options = nil, &block)
45
- if drivers[driver] && options
46
- raise "Driver #{driver} has already been created, options #{options} would be ignored!"
47
- end
48
- old_driver, old_options = @current_driver, @current_driver_options
49
- @current_driver, @current_driver_options = driver, options
50
- if block_given?
51
- begin
52
- yield
53
- ensure
54
- @current_driver, @current_driver_options = old_driver, old_options
55
- end
56
- end
57
- end
58
-
59
- def current_driver
60
- @current_driver || config[:driver]
61
- end
62
-
63
- def current_machine_options
64
- if @current_machine_options
65
- @current_machine_options
66
- else
67
- {}
68
- end
69
- end
70
-
71
- def current_image_options
72
- if @current_image_options
73
- @current_image_options
74
- else
75
- {}
76
- end
77
- end
78
-
79
- def add_machine_options(options, &block)
80
- with_machine_options(Chef::Mixin::DeepMerge.hash_only_merge(current_machine_options, options), &block)
81
- end
82
-
83
- def driver_for(driver)
84
- driver.is_a?(String) ? driver_for_url(driver) : driver
85
- end
86
-
87
- def connect_to_machine(name, chef_server = nil)
88
- if name.is_a?(ManagedEntry)
89
- machine_spec = name
90
- else
91
- machine_spec = Provisioning.chef_managed_entry_store(chef_server).get(:machine, name)
92
- end
93
- Chef::Provisioning.connect_to_machine(machine_spec, config)
94
- end
95
-
96
- private
97
-
98
- def driver_for_url(driver_url)
99
- drivers[driver_url] ||= begin
100
- if driver_url == @current_driver && @current_driver_options
101
- # Use the driver options if available
102
- merged_config = Cheffish::MergedConfig.new({ :driver_options => @current_driver_options }, config)
103
- driver = Chef::Provisioning.driver_for_url(driver_url, merged_config)
104
- else
105
- driver = Chef::Provisioning.driver_for_url(driver_url, config)
106
- end
107
- # Check the canonicalized driver_url from the driver
108
- if driver.driver_url != driver_url
109
- if drivers[driver.driver_url] && @current_driver_options
110
- raise "Canonical driver #{driver.driver_url} for #{driver_url} has already been created! Current options #{@current_driver_options} would be ignored."
111
- end
112
- drivers[driver.driver_url] ||= driver
113
- else
114
- driver
115
- end
116
- end
117
- end
118
-
119
- def keys
120
- result = (config.keys || {}).dup
121
- Array(config.key_path) do |key_path|
122
- Dir.entries(key_path).each do |key|
123
- if File.extname(key) == '.pem'
124
- result[File.basename(key)[0..-5]] ||= key
125
- end
126
- end
127
- end
128
- result
129
- end
130
- end
131
- end
132
- end
1
+ require 'chef/mixin/deep_merge'
2
+ require 'cheffish/merged_config'
3
+
4
+ class Chef
5
+ module Provisioning
6
+ class ChefRunData
7
+
8
+ def initialize(config)
9
+ @config = config
10
+ @drivers = {}
11
+ end
12
+
13
+ attr_reader :config
14
+ attr_reader :drivers
15
+ attr_reader :current_driver
16
+ attr_accessor :current_machine_options
17
+ attr_accessor :current_load_balancer_options
18
+ attr_accessor :current_image_options
19
+
20
+ def with_machine_options(value)
21
+ old_value = self.current_machine_options
22
+ self.current_machine_options = value
23
+ if block_given?
24
+ begin
25
+ yield
26
+ ensure
27
+ self.current_machine_options = old_value
28
+ end
29
+ end
30
+ end
31
+
32
+ def with_image_options(value)
33
+ old_value = self.current_image_options
34
+ self.current_image_options = value
35
+ if block_given?
36
+ begin
37
+ yield
38
+ ensure
39
+ self.current_image_options = old_value
40
+ end
41
+ end
42
+ end
43
+
44
+ def with_driver(driver, options = nil, &block)
45
+ if drivers[driver] && options
46
+ raise "Driver #{driver} has already been created, options #{options} would be ignored!"
47
+ end
48
+ old_driver, old_options = @current_driver, @current_driver_options
49
+ @current_driver, @current_driver_options = driver, options
50
+ if block_given?
51
+ begin
52
+ yield
53
+ ensure
54
+ @current_driver, @current_driver_options = old_driver, old_options
55
+ end
56
+ end
57
+ end
58
+
59
+ def current_driver
60
+ @current_driver || config[:driver]
61
+ end
62
+
63
+ def current_machine_options
64
+ if @current_machine_options
65
+ @current_machine_options
66
+ else
67
+ {}
68
+ end
69
+ end
70
+
71
+ def current_image_options
72
+ if @current_image_options
73
+ @current_image_options
74
+ else
75
+ {}
76
+ end
77
+ end
78
+
79
+ def add_machine_options(options, &block)
80
+ with_machine_options(Chef::Mixin::DeepMerge.hash_only_merge(current_machine_options, options), &block)
81
+ end
82
+
83
+ def driver_for(driver)
84
+ driver.is_a?(String) ? driver_for_url(driver) : driver
85
+ end
86
+
87
+ def connect_to_machine(name, chef_server = nil)
88
+ if name.is_a?(ManagedEntry)
89
+ machine_spec = name
90
+ else
91
+ machine_spec = Provisioning.chef_managed_entry_store(chef_server).get(:machine, name)
92
+ end
93
+ Chef::Provisioning.connect_to_machine(machine_spec, config)
94
+ end
95
+
96
+ private
97
+
98
+ def driver_for_url(driver_url)
99
+ drivers[driver_url] ||= begin
100
+ if driver_url == @current_driver && @current_driver_options
101
+ # Use the driver options if available
102
+ merged_config = Cheffish::MergedConfig.new({ :driver_options => @current_driver_options }, config)
103
+ driver = Chef::Provisioning.driver_for_url(driver_url, merged_config)
104
+ else
105
+ driver = Chef::Provisioning.driver_for_url(driver_url, config)
106
+ end
107
+ # Check the canonicalized driver_url from the driver
108
+ if driver.driver_url != driver_url
109
+ if drivers[driver.driver_url] && @current_driver_options
110
+ raise "Canonical driver #{driver.driver_url} for #{driver_url} has already been created! Current options #{@current_driver_options} would be ignored."
111
+ end
112
+ drivers[driver.driver_url] ||= driver
113
+ else
114
+ driver
115
+ end
116
+ end
117
+ end
118
+
119
+ def keys
120
+ result = (config.keys || {}).dup
121
+ Array(config.key_path) do |key_path|
122
+ Dir.entries(key_path).each do |key|
123
+ if File.extname(key) == '.pem'
124
+ result[File.basename(key)[0..-5]] ||= key
125
+ end
126
+ end
127
+ end
128
+ result
129
+ end
130
+ end
131
+ end
132
+ end
@@ -1,28 +1,28 @@
1
- class Chef
2
- module Provisioning
3
- class ConvergenceStrategy
4
- # convergence_options - a freeform hash of options to the converger.
5
- # config - a Chef::Config-like object with global config like :log_level
6
- def initialize(convergence_options, config)
7
- @convergence_options = convergence_options || {}
8
- @config = config
9
- end
10
-
11
- attr_reader :convergence_options
12
- attr_reader :config
13
-
14
- # Get the machine ready to converge, but do not converge.
15
- def setup_convergence(action_handler, machine)
16
- raise "setup_convergence not overridden on #{self.class}"
17
- end
18
-
19
- def converge(action_handler, machine)
20
- raise "converge not overridden on #{self.class}"
21
- end
22
-
23
- def cleanup_convergence(action_handler, machine_spec)
24
- raise "cleanup_convergence not overridden on #{self.class}"
25
- end
26
- end
27
- end
28
- end
1
+ class Chef
2
+ module Provisioning
3
+ class ConvergenceStrategy
4
+ # convergence_options - a freeform hash of options to the converger.
5
+ # config - a Chef::Config-like object with global config like :log_level
6
+ def initialize(convergence_options, config)
7
+ @convergence_options = convergence_options || {}
8
+ @config = config
9
+ end
10
+
11
+ attr_reader :convergence_options
12
+ attr_reader :config
13
+
14
+ # Get the machine ready to converge, but do not converge.
15
+ def setup_convergence(action_handler, machine)
16
+ raise "setup_convergence not overridden on #{self.class}"
17
+ end
18
+
19
+ def converge(action_handler, machine)
20
+ raise "converge not overridden on #{self.class}"
21
+ end
22
+
23
+ def cleanup_convergence(action_handler, machine_spec)
24
+ raise "cleanup_convergence not overridden on #{self.class}"
25
+ end
26
+ end
27
+ end
28
+ end