chef-provisioning 1.3.0 → 1.4.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.
@@ -42,7 +42,7 @@ module Provisioning
42
42
  install_command = Mixlib::Install.new(chef_version, false, opts).install_command
43
43
  machine.write_file(action_handler, install_sh_path, install_command, :ensure_dir => true)
44
44
  machine.set_attributes(action_handler, install_sh_path, :mode => '0755')
45
- machine.execute(action_handler, "sh -c #{install_sh_path}")
45
+ machine.execute(action_handler, "sh -c '#{install_sh_path} #{install_sh_arguments}'")
46
46
  end
47
47
 
48
48
  def converge(action_handler, machine)
@@ -2,11 +2,20 @@ require 'chef/provisioning/convergence_strategy'
2
2
  require 'pathname'
3
3
  require 'cheffish'
4
4
  require 'chef_zero/socketless_server_map'
5
+ require_relative 'ignore_convergence_failure'
5
6
 
6
7
  class Chef
7
8
  module Provisioning
8
9
  class ConvergenceStrategy
9
10
  class PrecreateChefObjects < ConvergenceStrategy
11
+
12
+ def initialize(convergence_options, config)
13
+ super
14
+ if convergence_options[:ignore_failure]
15
+ extend IgnoreConvergenceFailure
16
+ end
17
+ end
18
+
10
19
  def chef_server
11
20
  @chef_server ||= convergence_options[:chef_server] || Cheffish.default_chef_server(config)
12
21
  end
@@ -308,3 +308,16 @@ module Provisioning
308
308
  end
309
309
  end
310
310
  end
311
+
312
+ # In chef-provisioning we don't perform resource cloning
313
+ # This fixes resource cloning when the ResourceBuilder is present
314
+
315
+ class Chef
316
+ class ResourceBuilder
317
+ if defined?(:prior_resource)
318
+ def prior_resource
319
+ # NOOP
320
+ end
321
+ end
322
+ end
323
+ end
@@ -226,6 +226,13 @@ elif test "x$os" = "xAIX"; then
226
226
  platform="aix"
227
227
  platform_version=`uname -v`
228
228
  machine="ppc"
229
+ elif test -f "/etc/os-release"; then
230
+ . /etc/os-release
231
+ if test "x$ID_LIKE" = "xwrlinux" || test "x$ID_LIKE" = "xcisco-wrlinux"; then
232
+ platform="wrlinux"
233
+ # 3.4.43-WR5.0.1.13_standard --> 5
234
+ platform_version=`uname -r | sed 's/.*-WR\([0-9]\+\).*/\1/'`
235
+ fi
229
236
  fi
230
237
 
231
238
  if test "x$platform" = "x"; then
@@ -75,6 +75,10 @@ EOM
75
75
  end
76
76
  end
77
77
 
78
+ def system_drive
79
+ transport.execute('$env:SystemDrive').stdout.strip
80
+ end
81
+
78
82
  # Set file attributes { :owner, :group, :rights }
79
83
  # def set_attributes(action_handler, path, attributes)
80
84
  # end
@@ -0,0 +1,27 @@
1
+ RSpec.shared_context "run with driver" do |driver_args|
2
+ require 'cheffish/rspec/chef_run_support'
3
+ extend Cheffish::RSpec::ChefRunSupport
4
+
5
+ include_context "with a chef repo"
6
+
7
+ driver_object = Chef::Provisioning.driver_for_url(driver_args[:driver_string])
8
+
9
+ # globally set this as the driver. overridden by a resource's :driver attribute.
10
+ before { Chef::Config.driver(driver_object) }
11
+
12
+ let(:provisioning_driver) { driver_object }
13
+
14
+ # only class methods are available outside of examples.
15
+ def self.with_chef_server(description = "is running", *options, &block)
16
+
17
+ # no need to repeat these every time.
18
+ args = { organization: "spec_tests", server_scope: :context, port: 8900..9000 }
19
+ args = args.merge(options.last) if options.last.is_a?(Hash)
20
+
21
+ # this ends up in ChefZero::RSpec::RSpecClassMethods#when_the_chef_server, which defines all its code
22
+ # inside an RSpec context and then runs `instance_eval` on &block--which means it's only available as a
23
+ # block operator. it's not obviously impossible to factor out the code into a shared_context that we could
24
+ # include as above with "with a chef repo", but that's a chef-zero patch.
25
+ when_the_chef_12_server description, args, &block
26
+ end
27
+ end
@@ -36,8 +36,11 @@ module Provisioning
36
36
  def execute(command, execute_options = {})
37
37
  output = with_execute_timeout(execute_options) do
38
38
  session.set_timeout(execute_timeout(execute_options))
39
- session.run_powershell_script(command) do |stdout, stderr|
40
- stream_chunk(execute_options, stdout, stderr)
39
+ block = Proc.new { |stdout, stderr| stream_chunk(execute_options, stdout, stderr) }
40
+ if execute_options[:raw]
41
+ session.run_cmd(command, &block)
42
+ else
43
+ session.run_powershell_script(command, &block)
41
44
  end
42
45
  end
43
46
  WinRMResult.new(command, execute_options, config, output)
@@ -1,5 +1,5 @@
1
1
  class Chef
2
2
  module Provisioning
3
- VERSION = '1.3.0'
3
+ VERSION = '1.4.0'
4
4
  end
5
5
  end
@@ -0,0 +1,86 @@
1
+ require 'chef/provisioning/convergence_strategy/ignore_convergence_failure'
2
+
3
+ class TestConvergenceStrategyError < RuntimeError; end
4
+
5
+ class TestConvergeClass
6
+ attr_reader :convergence_options, :test_error
7
+ def initialize(convergence_options, test_error)
8
+ @convergence_options = convergence_options
9
+ @test_error = test_error
10
+ end
11
+ def converge(action_handler, machine)
12
+ test_error.call
13
+ end
14
+ end
15
+
16
+ describe Chef::Provisioning::ConvergenceStrategy::IgnoreConvergenceFailure do
17
+
18
+ let(:test_class) do
19
+ t = TestConvergeClass.new(convergence_options, test_error)
20
+ t.extend(Chef::Provisioning::ConvergenceStrategy::IgnoreConvergenceFailure)
21
+ t
22
+ end
23
+ let(:action_handler) { double("ActionHandler") }
24
+
25
+ shared_examples "does not raise an error" do
26
+ it "does not raise an error" do
27
+ expect(action_handler).to receive(:performed_action)
28
+ expect { test_class.converge(action_handler, nil) }.to_not raise_error
29
+ end
30
+ end
31
+
32
+ context "when ignore_failures is a single Fixnum" do
33
+ let(:convergence_options) { {ignore_failure: 1} }
34
+ let(:test_error) { proc { exit(1) } }
35
+ include_examples "does not raise an error"
36
+ end
37
+
38
+ context "when ignore_failures is an array of Fixnum" do
39
+ let(:convergence_options) { {ignore_failure: [1, 2]} }
40
+ let(:test_error) { proc { exit(1) } }
41
+ include_examples "does not raise an error"
42
+ end
43
+
44
+ context "when ignore_failures is a Range" do
45
+ let(:convergence_options) { {ignore_failure: [1, 5..10]} }
46
+ let(:test_error) { proc { exit(6) } }
47
+ include_examples "does not raise an error"
48
+ end
49
+
50
+ context "when ignore_failures is a single error class" do
51
+ let(:convergence_options) { {ignore_failure: TestConvergenceStrategyError} }
52
+ let(:test_error) { proc { raise TestConvergenceStrategyError } }
53
+ include_examples "does not raise an error"
54
+ end
55
+
56
+ context "when ignore_failures is an array of errors" do
57
+ let(:convergence_options) { {ignore_failure: [TestConvergenceStrategyError, NoMethodError]} }
58
+ let(:test_error) { proc { raise TestConvergenceStrategyError } }
59
+ include_examples "does not raise an error"
60
+ end
61
+
62
+ context "when ignore_failures is a different error" do
63
+ let(:convergence_options) { {ignore_failure: [NoMethodError]} }
64
+ let(:test_error) { proc { raise TestConvergenceStrategyError } }
65
+ it "does not catch the TestConvergenceStrategyError" do
66
+ expect { test_class.converge(action_handler, nil) }.to raise_error(TestConvergenceStrategyError)
67
+ end
68
+ end
69
+
70
+ context "when ignore_failures is true" do
71
+ let(:convergence_options) { {ignore_failure: true} }
72
+
73
+ context "and test_error is a RuntimeError" do
74
+ let(:test_error) { proc { raise TestConvergenceStrategyError } }
75
+ include_examples "does not raise an error"
76
+ end
77
+
78
+ context "and test_error is a SystemExit error" do
79
+ let(:test_error) { proc { exit(1) } }
80
+ it "does not catch SystemExit errors" do
81
+ expect { test_class.converge(action_handler, nil) }.to raise_error(SystemExit)
82
+ end
83
+ end
84
+ end
85
+
86
+ end
@@ -0,0 +1,27 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ # add_filter do |source_file|
4
+ # # source_file.lines.count < 5
5
+ # source.filename =~ /^#{SimpleCov.root}\/chef-provisioning-fake/)
6
+ # end
7
+ end
8
+
9
+ RSpec.configure do |config|
10
+ config.expect_with :rspec do |expectations|
11
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
12
+ end
13
+
14
+ config.mock_with :rspec do |mocks|
15
+ # Prevents you from mocking or stubbing a method that does not exist on
16
+ # a real object. This is generally recommended, and will default to
17
+ # `true` in RSpec 4.
18
+ mocks.verify_partial_doubles = true
19
+ end
20
+
21
+ config.run_all_when_everything_filtered = true
22
+ config.filter_run :focus
23
+ config.expect_with(:rspec) { |c| c.syntax = :expect }
24
+
25
+ #Chef::Log.level = :debug
26
+ # Chef::Config[:log_level] = :warn
27
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
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-08-05 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: chef
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 11.16.4
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 11.16.4
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: net-ssh
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +72,20 @@ dependencies:
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '1.1'
75
+ version: '1.3'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 1.3.1
90
79
  type: :runtime
91
80
  prerelease: false
92
81
  version_requirements: !ruby/object:Gem::Requirement
93
82
  requirements:
94
83
  - - "~>"
95
84
  - !ruby/object:Gem::Version
96
- version: '1.1'
85
+ version: '1.3'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 1.3.1
97
89
  - !ruby/object:Gem::Dependency
98
90
  name: winrm
99
91
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +106,34 @@ dependencies:
114
106
  requirements:
115
107
  - - "~>"
116
108
  - !ruby/object:Gem::Version
117
- version: '0.4'
109
+ version: '0.6'
118
110
  type: :runtime
119
111
  prerelease: false
120
112
  version_requirements: !ruby/object:Gem::Requirement
121
113
  requirements:
122
114
  - - "~>"
123
115
  - !ruby/object:Gem::Version
124
- version: '0.4'
116
+ version: '0.6'
117
+ - !ruby/object:Gem::Dependency
118
+ name: chef
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '12.1'
124
+ - - "!="
125
+ - !ruby/object:Gem::Version
126
+ version: 12.4.0
127
+ type: :development
128
+ prerelease: false
129
+ version_requirements: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - "~>"
132
+ - !ruby/object:Gem::Version
133
+ version: '12.1'
134
+ - - "!="
135
+ - !ruby/object:Gem::Version
136
+ version: 12.4.0
125
137
  - !ruby/object:Gem::Dependency
126
138
  name: rspec
127
139
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +176,20 @@ dependencies:
164
176
  - - ">="
165
177
  - !ruby/object:Gem::Version
166
178
  version: '0'
179
+ - !ruby/object:Gem::Dependency
180
+ name: simplecov
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
167
193
  description: A library for creating machines and infrastructures idempotently in Chef.
168
194
  email: jkeiser@chef.io
169
195
  executables: []
@@ -190,6 +216,7 @@ files:
190
216
  - lib/chef/provisioning/chef_provider_action_handler.rb
191
217
  - lib/chef/provisioning/chef_run_data.rb
192
218
  - lib/chef/provisioning/convergence_strategy.rb
219
+ - lib/chef/provisioning/convergence_strategy/ignore_convergence_failure.rb
193
220
  - lib/chef/provisioning/convergence_strategy/install_cached.rb
194
221
  - lib/chef/provisioning/convergence_strategy/install_msi.rb
195
222
  - lib/chef/provisioning/convergence_strategy/install_sh.rb
@@ -206,6 +233,7 @@ files:
206
233
  - lib/chef/provisioning/managed_entry.rb
207
234
  - lib/chef/provisioning/managed_entry_store.rb
208
235
  - lib/chef/provisioning/recipe_dsl.rb
236
+ - lib/chef/provisioning/rspec.rb
209
237
  - lib/chef/provisioning/transport.rb
210
238
  - lib/chef/provisioning/transport/ssh.rb
211
239
  - lib/chef/provisioning/transport/winrm.rb
@@ -218,6 +246,8 @@ files:
218
246
  - lib/chef/resource/machine_file.rb
219
247
  - lib/chef/resource/machine_image.rb
220
248
  - lib/chef_metal.rb
249
+ - spec/chef/provisioning/convergence_strategy/ignore_convergence_failure_spec.rb
250
+ - spec/spec_helper.rb
221
251
  homepage: http://github.com/chef/chef-provisioning/README.md
222
252
  licenses: []
223
253
  metadata: {}
@@ -237,8 +267,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
267
  version: '0'
238
268
  requirements: []
239
269
  rubyforge_project:
240
- rubygems_version: 2.4.7
270
+ rubygems_version: 2.4.5
241
271
  signing_key:
242
272
  specification_version: 4
243
273
  summary: A library for creating machines and infrastructures idempotently in Chef.
244
274
  test_files: []
275
+ has_rdoc: