chef-provisioning 2.0.0 → 2.0.1

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 +899 -885
  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 -35
  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 -156
  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 -29
  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 +5 -5
@@ -1,136 +1,136 @@
1
- require 'chef/provisioning/load_balancer_spec'
2
- require 'chef/provisioning/machine_spec'
3
- require 'chef/provisioning/machine_image_spec'
4
- require 'chef/provisioning/managed_entry'
5
-
6
- class Chef
7
- module Provisioning
8
- class ManagedEntryStore
9
- def initialize(chef_run_data)
10
- @chef_run_data = chef_run_data
11
- end
12
-
13
- #
14
- # Get the given data
15
- #
16
- # @param resource_type [Symbol] The type of thing to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
17
- # @param name [String] The unique identifier of the thing to retrieve
18
- #
19
- # @return [Hash,Array] The data. Will be JSON- and YAML-compatible (Hash, Array, String, Integer, Boolean, Nil)
20
- #
21
- def get_data(resource_type, name)
22
- raise NotImplementedError, :get_data
23
- end
24
-
25
- #
26
- # Save the given data
27
- #
28
- # @param resource_type [Symbol] The type of thing to save (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet ...)
29
- # @param name [String] The unique identifier of the thing to save
30
- # @param data [Hash,Array] The data to save. Must be JSON- and YAML-compatible (Hash, Array, String, Integer, Boolean, Nil)
31
- #
32
- def save_data(resource_type, name, data, action_handler)
33
- raise NotImplementedError, :save_data
34
- end
35
-
36
- #
37
- # Delete the given data
38
- #
39
- # @param resource_type [Symbol] The type of thing to delete (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
40
- # @param name [String] The unique identifier of the thing to delete
41
- #
42
- # @return [Boolean] Whether anything was deleted or not.
43
- #
44
- def delete_data(resource_type, name, action_handler)
45
- raise NotImplementedError, :delete_data
46
- end
47
-
48
- #
49
- # Get a globally unique identifier for this resource.
50
- #
51
- # @param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
52
- # @param name [String] The unique identifier of the spec to retrieve
53
- #
54
- # @return [String] The identifier.
55
- #
56
- # @example ChefManagedEntry does this:
57
- # chef_managed_entry_store.identifier(:machine, 'mario') # => https://my.chef.server/organizations/org/nodes/mario
58
- #
59
- def identifier(resource_type, name)
60
- raise NotImplementedError, :identifier
61
- end
62
-
63
- #
64
- # Get a spec.
65
- #
66
- # @param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
67
- # @param name [String] The unique identifier of the spec to retrieve
68
- #
69
- # @return [ManagedEntry] The entry, or `nil` if the data does not exist.
70
- #
71
- def get(resource_type, name)
72
- data = get_data(resource_type, name)
73
- if data
74
- new_entry(resource_type, name, data)
75
- end
76
- end
77
-
78
- #
79
- # Get a spec, or create a new one, depending on whether an entry exists.
80
- #
81
- # @param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
82
- # @param name [String] The unique identifier of the spec to retrieve
83
- #
84
- # @return [ManagedEntry] The entry.
85
- #
86
- def get_or_new(resource_type, name)
87
- data = get_data(resource_type, name)
88
- new_entry(resource_type, name, data)
89
- end
90
-
91
- #
92
- # Get a spec, erroring out if the data does not exist.
93
- #
94
- # @param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
95
- # @param name [String] The unique identifier of the spec to retrieve
96
- #
97
- # @return [ManagedEntry] The entry.
98
- #
99
- def get!(resource_type, name)
100
- result = get(resource_type, name)
101
- if !result
102
- raise "#{identifier(resource_type, name)} not found!"
103
- end
104
- result
105
- end
106
-
107
- #
108
- # Delete the given spec.
109
- #
110
- # @param resource_type [Symbol] The type of spec to delete (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
111
- # @param name [String] The unique identifier of the spec to delete
112
- #
113
- # @return [Boolean] Whether anything was deleted or not.
114
- #
115
- def delete(resource_type, name, action_handler)
116
- delete_data(resource_type, name, action_handler)
117
- end
118
-
119
- #
120
- # Create a new managed entry of the given type.
121
- #
122
- def new_entry(resource_type, name, data=nil)
123
- case resource_type
124
- when :machine
125
- MachineSpec.new(self, resource_type, name, data)
126
- when :machine_image
127
- MachineImageSpec.new(self, resource_type, name, data)
128
- when :load_balancer
129
- LoadBalancerSpec.new(self, resource_type, name, data)
130
- else
131
- ManagedEntry.new(self, resource_type, name, data)
132
- end
133
- end
134
- end
135
- end
136
- end
1
+ require 'chef/provisioning/load_balancer_spec'
2
+ require 'chef/provisioning/machine_spec'
3
+ require 'chef/provisioning/machine_image_spec'
4
+ require 'chef/provisioning/managed_entry'
5
+
6
+ class Chef
7
+ module Provisioning
8
+ class ManagedEntryStore
9
+ def initialize(chef_run_data)
10
+ @chef_run_data = chef_run_data
11
+ end
12
+
13
+ #
14
+ # Get the given data
15
+ #
16
+ # @param resource_type [Symbol] The type of thing to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
17
+ # @param name [String] The unique identifier of the thing to retrieve
18
+ #
19
+ # @return [Hash,Array] The data. Will be JSON- and YAML-compatible (Hash, Array, String, Integer, Boolean, Nil)
20
+ #
21
+ def get_data(resource_type, name)
22
+ raise NotImplementedError, :get_data
23
+ end
24
+
25
+ #
26
+ # Save the given data
27
+ #
28
+ # @param resource_type [Symbol] The type of thing to save (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet ...)
29
+ # @param name [String] The unique identifier of the thing to save
30
+ # @param data [Hash,Array] The data to save. Must be JSON- and YAML-compatible (Hash, Array, String, Integer, Boolean, Nil)
31
+ #
32
+ def save_data(resource_type, name, data, action_handler)
33
+ raise NotImplementedError, :save_data
34
+ end
35
+
36
+ #
37
+ # Delete the given data
38
+ #
39
+ # @param resource_type [Symbol] The type of thing to delete (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
40
+ # @param name [String] The unique identifier of the thing to delete
41
+ #
42
+ # @return [Boolean] Whether anything was deleted or not.
43
+ #
44
+ def delete_data(resource_type, name, action_handler)
45
+ raise NotImplementedError, :delete_data
46
+ end
47
+
48
+ #
49
+ # Get a globally unique identifier for this resource.
50
+ #
51
+ # @param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
52
+ # @param name [String] The unique identifier of the spec to retrieve
53
+ #
54
+ # @return [String] The identifier.
55
+ #
56
+ # @example ChefManagedEntry does this:
57
+ # chef_managed_entry_store.identifier(:machine, 'mario') # => https://my.chef.server/organizations/org/nodes/mario
58
+ #
59
+ def identifier(resource_type, name)
60
+ raise NotImplementedError, :identifier
61
+ end
62
+
63
+ #
64
+ # Get a spec.
65
+ #
66
+ # @param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
67
+ # @param name [String] The unique identifier of the spec to retrieve
68
+ #
69
+ # @return [ManagedEntry] The entry, or `nil` if the data does not exist.
70
+ #
71
+ def get(resource_type, name)
72
+ data = get_data(resource_type, name)
73
+ if data
74
+ new_entry(resource_type, name, data)
75
+ end
76
+ end
77
+
78
+ #
79
+ # Get a spec, or create a new one, depending on whether an entry exists.
80
+ #
81
+ # @param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
82
+ # @param name [String] The unique identifier of the spec to retrieve
83
+ #
84
+ # @return [ManagedEntry] The entry.
85
+ #
86
+ def get_or_new(resource_type, name)
87
+ data = get_data(resource_type, name)
88
+ new_entry(resource_type, name, data)
89
+ end
90
+
91
+ #
92
+ # Get a spec, erroring out if the data does not exist.
93
+ #
94
+ # @param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
95
+ # @param name [String] The unique identifier of the spec to retrieve
96
+ #
97
+ # @return [ManagedEntry] The entry.
98
+ #
99
+ def get!(resource_type, name)
100
+ result = get(resource_type, name)
101
+ if !result
102
+ raise "#{identifier(resource_type, name)} not found!"
103
+ end
104
+ result
105
+ end
106
+
107
+ #
108
+ # Delete the given spec.
109
+ #
110
+ # @param resource_type [Symbol] The type of spec to delete (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, ...)
111
+ # @param name [String] The unique identifier of the spec to delete
112
+ #
113
+ # @return [Boolean] Whether anything was deleted or not.
114
+ #
115
+ def delete(resource_type, name, action_handler)
116
+ delete_data(resource_type, name, action_handler)
117
+ end
118
+
119
+ #
120
+ # Create a new managed entry of the given type.
121
+ #
122
+ def new_entry(resource_type, name, data=nil)
123
+ case resource_type
124
+ when :machine
125
+ MachineSpec.new(self, resource_type, name, data)
126
+ when :machine_image
127
+ MachineImageSpec.new(self, resource_type, name, data)
128
+ when :load_balancer
129
+ LoadBalancerSpec.new(self, resource_type, name, data)
130
+ else
131
+ ManagedEntry.new(self, resource_type, name, data)
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
@@ -1,99 +1,99 @@
1
- require 'chef/provisioning/chef_run_data'
2
- require 'chef/resource_collection'
3
- require 'chef/resource/chef_data_bag_resource'
4
-
5
- require 'chef/resource/machine'
6
- require 'chef/provider/machine'
7
- require 'chef/resource/machine_batch'
8
- require 'chef/provider/machine_batch'
9
- require 'chef/resource/machine_file'
10
- require 'chef/provider/machine_file'
11
- require 'chef/resource/machine_execute'
12
- require 'chef/provider/machine_execute'
13
- require 'chef/resource/machine_image'
14
- require 'chef/provider/machine_image'
15
- require 'chef/resource/load_balancer'
16
- require 'chef/provider/load_balancer'
17
-
18
- class Chef
19
- module DSL
20
- module Recipe
21
-
22
- def with_driver(driver, options = nil, &block)
23
- run_context.chef_provisioning.with_driver(driver, options, &block)
24
- end
25
-
26
- def with_machine_options(machine_options, &block)
27
- run_context.chef_provisioning.with_machine_options(machine_options, &block)
28
- end
29
-
30
- def current_machine_options
31
- run_context.chef_provisioning.current_machine_options
32
- end
33
-
34
- def add_machine_options(options, &block)
35
- run_context.chef_provisioning.add_machine_options(options, &block)
36
- end
37
-
38
- def with_image_options(image_options, &block)
39
- run_context.chef_provisioning.with_image_options(image_options, &block)
40
- end
41
-
42
- def current_image_options
43
- run_context.chef_provisioning.current_image_options
44
- end
45
-
46
- NOT_PASSED = Object.new
47
-
48
- @@next_machine_batch_index = 0
49
-
50
- def machine_batch_default_name
51
- @@next_machine_batch_index += 1
52
- if @@next_machine_batch_index > 1
53
- "default#{@@next_machine_batch_index}"
54
- else
55
- "default"
56
- end
57
- end
58
-
59
- def machine_batch(name = nil, &block)
60
- name ||= machine_batch_default_name
61
- recipe = self
62
- declare_resource(:machine_batch, name, caller[0]) do
63
- from_recipe recipe
64
- instance_eval(&block)
65
- end
66
- end
67
-
68
- end
69
- end
70
-
71
- class Config
72
- default(:driver) { ENV['CHEF_DRIVER'] }
73
- # config_context :drivers do
74
- # # each key is a driver_url, and each value can have driver, driver_options and machine_options
75
- # config_strict_mode false
76
- # end
77
- # config_context :driver_options do
78
- # # open ended for whatever the driver wants
79
- # config_strict_mode false
80
- # end
81
- # config_context :machine_options do
82
- # # open ended for whatever the driver wants
83
- # config_strict_mode false
84
- # end
85
- end
86
-
87
- class RunContext
88
- def chef_provisioning
89
- node.run_state[:chef_provisioning] ||= Chef::Provisioning::ChefRunData.new(config)
90
- end
91
- alias :chef_metal :chef_provisioning
92
- end
93
-
94
- class ResourceCollection
95
- def previous_index
96
- @insert_after_idx ? @insert_after_idx : @resources.length - 1
97
- end
98
- end
99
- end
1
+ require 'chef/provisioning/chef_run_data'
2
+ require 'chef/resource_collection'
3
+ require 'chef/resource/chef_data_bag_resource'
4
+
5
+ require 'chef/resource/machine'
6
+ require 'chef/provider/machine'
7
+ require 'chef/resource/machine_batch'
8
+ require 'chef/provider/machine_batch'
9
+ require 'chef/resource/machine_file'
10
+ require 'chef/provider/machine_file'
11
+ require 'chef/resource/machine_execute'
12
+ require 'chef/provider/machine_execute'
13
+ require 'chef/resource/machine_image'
14
+ require 'chef/provider/machine_image'
15
+ require 'chef/resource/load_balancer'
16
+ require 'chef/provider/load_balancer'
17
+
18
+ class Chef
19
+ module DSL
20
+ module Recipe
21
+
22
+ def with_driver(driver, options = nil, &block)
23
+ run_context.chef_provisioning.with_driver(driver, options, &block)
24
+ end
25
+
26
+ def with_machine_options(machine_options, &block)
27
+ run_context.chef_provisioning.with_machine_options(machine_options, &block)
28
+ end
29
+
30
+ def current_machine_options
31
+ run_context.chef_provisioning.current_machine_options
32
+ end
33
+
34
+ def add_machine_options(options, &block)
35
+ run_context.chef_provisioning.add_machine_options(options, &block)
36
+ end
37
+
38
+ def with_image_options(image_options, &block)
39
+ run_context.chef_provisioning.with_image_options(image_options, &block)
40
+ end
41
+
42
+ def current_image_options
43
+ run_context.chef_provisioning.current_image_options
44
+ end
45
+
46
+ NOT_PASSED = Object.new
47
+
48
+ @@next_machine_batch_index = 0
49
+
50
+ def machine_batch_default_name
51
+ @@next_machine_batch_index += 1
52
+ if @@next_machine_batch_index > 1
53
+ "default#{@@next_machine_batch_index}"
54
+ else
55
+ "default"
56
+ end
57
+ end
58
+
59
+ def machine_batch(name = nil, &block)
60
+ name ||= machine_batch_default_name
61
+ recipe = self
62
+ declare_resource(:machine_batch, name, caller[0]) do
63
+ from_recipe recipe
64
+ instance_eval(&block)
65
+ end
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ class Config
72
+ default(:driver) { ENV['CHEF_DRIVER'] }
73
+ # config_context :drivers do
74
+ # # each key is a driver_url, and each value can have driver, driver_options and machine_options
75
+ # config_strict_mode false
76
+ # end
77
+ # config_context :driver_options do
78
+ # # open ended for whatever the driver wants
79
+ # config_strict_mode false
80
+ # end
81
+ # config_context :machine_options do
82
+ # # open ended for whatever the driver wants
83
+ # config_strict_mode false
84
+ # end
85
+ end
86
+
87
+ class RunContext
88
+ def chef_provisioning
89
+ node.run_state[:chef_provisioning] ||= Chef::Provisioning::ChefRunData.new(config)
90
+ end
91
+ alias :chef_metal :chef_provisioning
92
+ end
93
+
94
+ class ResourceCollection
95
+ def previous_index
96
+ @insert_after_idx ? @insert_after_idx : @resources.length - 1
97
+ end
98
+ end
99
+ end