chef 15.5.9 → 15.5.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b826d0315123f87d4feb069a4289749d0bf5db9a76853499c80dcbddfdad2ed0
4
- data.tar.gz: 27867153b65d9cd6123d57898e1a9348490d163c7dea664448d1e275786dc2d3
3
+ metadata.gz: aa6f7fb37534f3527c432f9b6039aacda3cafce1a81ad5242ed1eec4313a5c2c
4
+ data.tar.gz: c165dd8c93fa333de32dd539b1dce96c89419703ed4c5df6ff96cd598eb0e333
5
5
  SHA512:
6
- metadata.gz: 29e068c32113545d82e3d83cfaff2966dd96ad08e8882861458354c9372707fb97a9846384e5e55078ee8b50fc06aa480a02f17e1a2201593460d991d9bbb3c0
7
- data.tar.gz: bc7f429bf5bb6b92667db0b2fde9117bc4806744aea7a1e43259e3693c86d2099f9fcedc989036b57e2dc9a6a1437db020bee675c0d0f6d8ca6b352b6a2f46e0
6
+ metadata.gz: 63f4653f9260614046557037009856e388d194f1114a7e782fd188680e1f7da648d8a7b88781609d4d1afefad2aaacb1fa27cc9ff52ac8a6c3458199378a71e3
7
+ data.tar.gz: 29179c29a61a4afa1cdcadd993f3720fa168dbe0186a21f9fa2e73d3e4d0bccf45125df8251507dd90e6167224dbb8104e2f13dc673fceed4e474c3ea5800cd9
data/Rakefile CHANGED
@@ -17,10 +17,14 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require_relative "tasks/rspec"
21
- require_relative "tasks/dependencies"
22
- require_relative "tasks/announce"
23
- require_relative "tasks/docs"
20
+ begin
21
+ require_relative "tasks/rspec"
22
+ require_relative "tasks/dependencies"
23
+ require_relative "tasks/announce"
24
+ require_relative "tasks/docs"
25
+ rescue LoadError => e
26
+ puts "Skipping missing rake dep: #{e}"
27
+ end
24
28
 
25
29
  ENV["CHEF_LICENSE"] = "accept-no-persist"
26
30
 
@@ -58,5 +58,8 @@ Gem::Specification.new do |s|
58
58
  s.executables = %w{ knife }
59
59
 
60
60
  s.require_paths = %w{ lib }
61
- s.files = %w{Gemfile Rakefile LICENSE README.md} + Dir.glob("{lib,tasks,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } + Dir.glob("*.gemspec")
61
+ s.files = %w{Gemfile Rakefile LICENSE README.md} +
62
+ Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } +
63
+ Dir.glob("*.gemspec") +
64
+ Dir.glob("tasks/rspec.rb")
62
65
  end
@@ -250,7 +250,7 @@ class Chef
250
250
  logger.info "#{Chef::Dist::CLIENT.capitalize} pid: #{Process.pid}"
251
251
  logger.info "Targeting node: #{Chef::Config.target_mode.host}" if Chef::Config.target_mode?
252
252
  logger.debug("#{Chef::Dist::CLIENT.capitalize} request_id: #{request_id}")
253
- ENV["PATH"] = ChefUtils::PathSanity.sanitized_path if Chef::Config[:enforce_path_sanity]
253
+ ENV["PATH"] = ChefUtils::DSL::PathSanity.sanitized_path if Chef::Config[:enforce_path_sanity]
254
254
 
255
255
  if Chef::Config.target_mode?
256
256
  get_ohai_data_remotely
@@ -43,7 +43,6 @@ require_relative "provider/noop"
43
43
  require_relative "provider/package"
44
44
  require_relative "provider/powershell_script"
45
45
  require_relative "provider/osx_profile"
46
- require_relative "provider/reboot"
47
46
  require_relative "provider/remote_directory"
48
47
  require_relative "provider/remote_file"
49
48
  require_relative "provider/route"
@@ -45,24 +45,28 @@ class Chef
45
45
  description: "Install the build essential packages at compile time.",
46
46
  default: false, desired_state: false
47
47
 
48
+ property :raise_if_unsupported, [TrueClass, FalseClass],
49
+ description: "Raise a hard error on platforms where this resource is unsupported.",
50
+ default: false, desired_state: false # FIXME: make this default to true
51
+
48
52
  action :install do
49
53
 
50
54
  description "Install build essential packages"
51
55
 
52
- case node["platform_family"]
53
- when "debian"
56
+ case
57
+ when debian?
54
58
  package %w{ autoconf binutils-doc bison build-essential flex gettext ncurses-dev }
55
- when fedora_derived?
56
- package %w{ autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch }
59
+ when fedora_derived?
60
+ package %w{ autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch }
57
61
 
58
62
  # Ensure GCC 4 is available on older pre-6 EL
59
- package %w{ gcc44 gcc44-c++ } if platform_family?("rhel") && node["platform_version"].to_i < 6
60
- when "freebsd"
63
+ package %w{ gcc44 gcc44-c++ } if platform_family?("rhel") && node["platform_version"].to_i < 6
64
+ when freebsd?
61
65
  package "devel/gmake"
62
66
  package "devel/autoconf"
63
67
  package "devel/m4"
64
68
  package "devel/gettext"
65
- when "mac_os_x"
69
+ when macos?
66
70
  unless xcode_cli_installed?
67
71
  # This script was graciously borrowed and modified from Tim Sutton's
68
72
  # osx-vm-templates at https://github.com/timsutton/osx-vm-templates/blob/b001475df54a9808d3d56d06e71b8fa3001fff42/scripts/xcode-cli-tools.sh
@@ -80,7 +84,7 @@ class Chef
80
84
  EOH
81
85
  end
82
86
  end
83
- when "omnios"
87
+ when omnios?
84
88
  package "developer/gcc48"
85
89
  package "developer/object-file"
86
90
  package "developer/linker"
@@ -93,7 +97,7 @@ class Chef
93
97
  # $PATH, so add it to the running process environment
94
98
  # http://omnios.omniti.com/wiki.php/DevEnv
95
99
  ENV["PATH"] = "#{ENV["PATH"]}:/opt/gcc-4.7.2/bin"
96
- when "solaris2"
100
+ when solaris2?
97
101
  package "autoconf"
98
102
  package "automake"
99
103
  package "bison"
@@ -111,21 +115,28 @@ class Chef
111
115
  package "make"
112
116
  package "pkg-config"
113
117
  package "ucb"
114
- when "smartos"
118
+ when smartos?
115
119
  package "autoconf"
116
120
  package "binutils"
117
121
  package "build-essential"
118
122
  package "gcc47"
119
123
  package "gmake"
120
124
  package "pkg-config"
121
- when "suse"
125
+ when suse?
122
126
  package %w{ autoconf bison flex gcc gcc-c++ kernel-default-devel make m4 }
123
127
  package %w{ gcc48 gcc48-c++ } if node["platform_version"].to_i < 12
124
128
  else
125
- Chef::Log.warn <<-EOH
129
+ if new_resource.raise_if_unsupported
130
+ raise <<-EOH
131
+ The build_essential resource does not currently support the '#{node["platform_family"]}'
132
+ platform family. Skipping...
133
+ EOH
134
+ else
135
+ Chef::Log.warn <<-EOH
126
136
  The build_essential resource does not currently support the '#{node["platform_family"]}'
127
137
  platform family. Skipping...
128
- EOH
138
+ EOH
139
+ end
129
140
  end
130
141
  end
131
142
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Chris Doherty <cdoherty@chef.io>)
3
- # Copyright:: Copyright 2014-2016, Chef, Inc.
3
+ # Copyright:: Copyright 2014-2019, Chef, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,6 +25,7 @@ class Chef
25
25
  unified_mode true
26
26
 
27
27
  resource_name :reboot
28
+ provides :reboot
28
29
 
29
30
  description "Use the reboot resource to reboot a node, a necessary step with some"\
30
31
  " installations on certain platforms. This resource is supported for use on"\
@@ -34,9 +35,6 @@ class Chef
34
35
  " probably undesired results."
35
36
  introduced "12.0"
36
37
 
37
- allowed_actions :request_reboot, :reboot_now, :cancel
38
- default_action :nothing # make sure people are quite clear what they want
39
-
40
38
  property :reason, String,
41
39
  description: "A string that describes the reboot action.",
42
40
  default: "Reboot by #{Chef::Dist::PRODUCT}"
@@ -44,6 +42,52 @@ class Chef
44
42
  property :delay_mins, Integer,
45
43
  description: "The amount of time (in minutes) to delay a reboot request.",
46
44
  default: 0
45
+
46
+ action :request_reboot do
47
+ description "Reboot a node at the end of a chef-client run."
48
+
49
+ converge_by("request a system reboot to occur if the run succeeds") do
50
+ logger.warn "Reboot requested:'#{new_resource.name}'"
51
+ request_reboot
52
+ end
53
+ end
54
+
55
+ action :reboot_now do
56
+ description "Reboot a node so that the chef-client may continue the installation process."
57
+
58
+ converge_by("rebooting the system immediately") do
59
+ logger.warn "Rebooting system immediately, requested by '#{new_resource.name}'"
60
+ request_reboot
61
+ throw :end_client_run_early
62
+ end
63
+ end
64
+
65
+ action :cancel do
66
+ description "Cancel a pending reboot request."
67
+
68
+ converge_by("cancel any existing end-of-run reboot request") do
69
+ logger.warn "Reboot canceled: '#{new_resource.name}'"
70
+ node.run_context.cancel_reboot
71
+ end
72
+ end
73
+
74
+ # make sure people are quite clear what they want
75
+ # we have to define this below the actions since setting default_action to :nothing is a no-op
76
+ # and doesn't actually override the first action in the resource
77
+ default_action :nothing
78
+
79
+ action_class do
80
+ # add a reboot to the node run_context
81
+ # @return [void]
82
+ def request_reboot
83
+ node.run_context.request_reboot(
84
+ delay_mins: new_resource.delay_mins,
85
+ reason: new_resource.reason,
86
+ timestamp: Time.now,
87
+ requested_by: new_resource.name
88
+ )
89
+ end
90
+ end
47
91
  end
48
92
  end
49
93
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Bryan McLellan <btm@loftninjas.org>
3
- # Copyright:: Copyright 2014-2017, Chef Software Inc.
3
+ # Copyright:: Copyright 2014-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +20,7 @@ require_relative "../mixin/uris"
20
20
  require_relative "package"
21
21
  require_relative "../provider/package/windows"
22
22
  require_relative "../win32/error" if RUBY_PLATFORM =~ /mswin|mingw|windows/
23
+ require_relative "../dist"
23
24
 
24
25
  class Chef
25
26
  class Resource
@@ -30,7 +31,7 @@ class Chef
30
31
  provides(:windows_package) { true }
31
32
  provides :package, os: "windows"
32
33
 
33
- description "Use the windows_package resource to manage Microsoft Installer Package (MSI) packages for the Microsoft Windows platform."
34
+ description "Use the windows_package resource to manage packages on the Microsoft Windows platform. The windows_package resource supports these installer formats:\n\n Microsoft Installer Package (MSI)\n Nullsoft Scriptable Install System (NSIS)\n Inno Setup (inno)\n Wise\n InstallShield\n Custom installers such as installing a non-.msi file that embeds an .msi-based installer\n"
34
35
  introduced "11.12"
35
36
 
36
37
  allowed_actions :install, :remove
@@ -41,21 +42,39 @@ class Chef
41
42
  end
42
43
 
43
44
  # windows can't take array options yet
44
- property :options, String
45
+ property :options, String,
46
+ description: "One (or more) additional options that are passed to the command."
45
47
 
46
48
  # Unique to this resource
47
- property :installer_type, Symbol
48
- property :timeout, [ String, Integer ], default: 600
49
+ property :installer_type, Symbol,
50
+ equal_to: %i{custom inno installshield msi nsis wise},
51
+ description: "A symbol that specifies the type of package. Possible values: :custom (such as installing a non-.msi file that embeds an .msi-based installer), :inno (Inno Setup), :installshield (InstallShield), :msi (Microsoft Installer Package (MSI)), :nsis (Nullsoft Scriptable Install System (NSIS)), :wise (Wise)."
52
+
53
+ property :timeout, [ String, Integer ], default: 600,
54
+ default_description: "600 (seconds)",
55
+ description: "The amount of time (in seconds) to wait before timing out."
56
+
49
57
  # In the past we accepted return code 127 for an unknown reason and 42 because of a bug
50
- property :returns, [ String, Integer, Array ], default: [ 0 ], desired_state: false
58
+ property :returns, [ String, Integer, Array ], default: [ 0 ],
59
+ desired_state: false,
60
+ description: "A comma-delimited list of return codes that indicate the success or failure of the package command that was run."
61
+
51
62
  property :source, String,
52
63
  coerce: (proc do |s|
53
64
  unless s.nil?
54
65
  uri_scheme?(s) ? s : Chef::Util::PathHelper.canonical_path(s, false)
55
66
  end
56
- end)
57
- property :checksum, String, desired_state: false
58
- property :remote_file_attributes, Hash, desired_state: false
67
+ end),
68
+ default_description: "The resource block's name", # this property is basically a name_property but not really so we need to spell it out
69
+ description: "The path to a package in the local file system. The location of the package may be at a URL. \n"
70
+
71
+ property :checksum, String,
72
+ desired_state: false, coerce: (proc { |c| c.downcase }),
73
+ description: "The SHA-256 checksum of the file. Use to prevent a file from being re-downloaded. When the local file matches the checksum, #{Chef::Dist::PRODUCT} does not download it. Use when a URL is specified by the source property."
74
+
75
+ property :remote_file_attributes, Hash,
76
+ desired_state: false,
77
+ description: "If the source package to install is at a remote location this property allows you to define a hash of properties and their value which will be used by the underlying remote_file resource, which fetches the source."
59
78
  end
60
79
  end
61
80
  end
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("15.5.9")
26
+ VERSION = Chef::VersionString.new("15.5.15")
27
27
  end
28
28
 
29
29
  #
File without changes
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Lamont Granquist (<lamont@chef.io>)
3
- # Copyright:: Copyright 2014-2018, Chef Software Inc.
3
+ # Copyright:: Copyright 2014-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -132,6 +132,10 @@ describe Chef::ProviderResolver do
132
132
  expect(expected_provider).to receive(:new).with(resource, run_context).and_return(provider)
133
133
  expect(resolved_provider).to eql(expected_provider)
134
134
  end
135
+ elsif expected_resource
136
+ it "'#{name}' resolves to resource #{expected_resource}", *tags do
137
+ expect(resource.class).to eql(expected_resource)
138
+ end
135
139
  else
136
140
  it "'#{name}' fails to resolve (since #{name.inspect} is unsupported on #{platform} #{platform_version})", *tags do
137
141
  Chef::Config[:treat_deprecation_warnings_as_errors] = false
@@ -583,6 +587,7 @@ describe Chef::ProviderResolver do
583
587
  windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ],
584
588
  windows_user: [ Chef::Resource::User::WindowsUser, Chef::Provider::User::Windows ],
585
589
  yum_package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ],
590
+ build_essential: [ Chef::Resource::BuildEssential ],
586
591
 
587
592
  "linux" => {
588
593
  "debian" => {
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Bryan McLellan <btm@loftninjas.org>
3
- # Copyright:: Copyright 2014-2016, Chef Software, Inc.
3
+ # Copyright:: Copyright 2014-2019, Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -51,9 +51,14 @@ describe Chef::Resource::WindowsPackage, "initialize" do
51
51
  expect { resource.action :upgrade }.not_to raise_error
52
52
  end
53
53
 
54
- it "supports setting installer_type as a symbol" do
55
- resource.installer_type(:msi)
56
- expect(resource.installer_type).to eql(:msi)
54
+ it "supports setting installer_type to :custom :inno :installshield :msi :nsis or :wise only" do
55
+ expect { resource.installer_type :custom }.not_to raise_error
56
+ expect { resource.installer_type :inno }.not_to raise_error
57
+ expect { resource.installer_type :installshield }.not_to raise_error
58
+ expect { resource.installer_type :msi }.not_to raise_error
59
+ expect { resource.installer_type :nsis }.not_to raise_error
60
+ expect { resource.installer_type :wise }.not_to raise_error
61
+ expect { resource.installer_type "msi" }.to raise_error(Chef::Exceptions::ValidationFailed)
57
62
  end
58
63
 
59
64
  # String, Integer
@@ -72,7 +77,7 @@ describe Chef::Resource::WindowsPackage, "initialize" do
72
77
  end
73
78
  end
74
79
 
75
- it "coverts a source to an absolute path" do
80
+ it "converts a source to an absolute path" do
76
81
  allow(::File).to receive(:absolute_path).and_return("c:\\files\\frost.msi")
77
82
  resource.source("frost.msi")
78
83
  expect(resource.source).to eql "c:\\files\\frost.msi"
@@ -89,8 +94,8 @@ describe Chef::Resource::WindowsPackage, "initialize" do
89
94
  expect(resource.source).to include("solitaire.msi")
90
95
  end
91
96
 
92
- it "supports the checksum property" do
93
- resource.checksum("somechecksum")
97
+ it "lowercases values provided in the checksum property" do
98
+ resource.checksum("SOMECHECKSUM")
94
99
  expect(resource.checksum).to eq("somechecksum")
95
100
  end
96
101
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.5.9
4
+ version: 15.5.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-15 00:00:00.000000000 Z
11
+ date: 2019-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 15.5.9
19
+ version: 15.5.15
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 15.5.9
26
+ version: 15.5.15
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 15.5.9
33
+ version: 15.5.15
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 15.5.9
40
+ version: 15.5.15
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -1096,7 +1096,6 @@ files:
1096
1096
  - lib/chef/provider/package/yum/yum_helper.py
1097
1097
  - lib/chef/provider/package/zypper.rb
1098
1098
  - lib/chef/provider/powershell_script.rb
1099
- - lib/chef/provider/reboot.rb
1100
1099
  - lib/chef/provider/registry_key.rb
1101
1100
  - lib/chef/provider/remote_directory.rb
1102
1101
  - lib/chef/provider/remote_file.rb
@@ -2605,12 +2604,7 @@ files:
2605
2604
  - spec/unit/win32/registry_spec.rb
2606
2605
  - spec/unit/win32/security_spec.rb
2607
2606
  - spec/unit/windows_service_spec.rb
2608
- - tasks/announce.rb
2609
- - tasks/bin/run_external_test
2610
- - tasks/dependencies.rb
2611
- - tasks/docs.rb
2612
2607
  - tasks/rspec.rb
2613
- - tasks/templates/release.md.erb
2614
2608
  homepage: https://www.chef.io
2615
2609
  licenses:
2616
2610
  - Apache-2.0
@@ -1,78 +0,0 @@
1
- #
2
- # Author:: Chris Doherty <cdoherty@chef.io>)
3
- # Copyright:: Copyright 2014-2016, Chef, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require_relative "../log"
20
- require_relative "../provider"
21
-
22
- class Chef
23
- class Provider
24
- # Use the reboot resource to reboot a node, a necessary step with some
25
- # installations on certain platforms. This resource is supported for use on
26
- # the Microsoft Windows, macOS, and Linux platforms.
27
- #
28
- # In using this resource via notifications, it's important to *only* use
29
- # immediate notifications. Delayed notifications produce unintuitive and
30
- # probably undesired results.
31
- #
32
- # @since 12.0.0
33
- class Reboot < Chef::Provider
34
- provides :reboot
35
-
36
- # @return [void]
37
- def load_current_resource
38
- @current_resource ||= Chef::Resource::Reboot.new(new_resource.name)
39
- current_resource.reason(new_resource.reason)
40
- current_resource.delay_mins(new_resource.delay_mins)
41
- current_resource
42
- end
43
-
44
- # add a reboot to the node run_context
45
- # @return [void]
46
- def request_reboot
47
- node.run_context.request_reboot(
48
- delay_mins: new_resource.delay_mins,
49
- reason: new_resource.reason,
50
- timestamp: Time.now,
51
- requested_by: new_resource.name
52
- )
53
- end
54
-
55
- def action_request_reboot
56
- converge_by("request a system reboot to occur if the run succeeds") do
57
- logger.warn "Reboot requested:'#{new_resource.name}'"
58
- request_reboot
59
- end
60
- end
61
-
62
- def action_reboot_now
63
- converge_by("rebooting the system immediately") do
64
- logger.warn "Rebooting system immediately, requested by '#{new_resource.name}'"
65
- request_reboot
66
- throw :end_client_run_early
67
- end
68
- end
69
-
70
- def action_cancel
71
- converge_by("cancel any existing end-of-run reboot request") do
72
- logger.warn "Reboot canceled: '#{new_resource.name}'"
73
- node.run_context.cancel_reboot
74
- end
75
- end
76
- end
77
- end
78
- end
@@ -1,51 +0,0 @@
1
- #
2
- # Copyright:: Copyright 2016-2018, Chef Software Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require "date"
19
- require "erb"
20
-
21
- class ReleaseAnnouncement
22
- include ERB::Util
23
- attr_accessor :type, :version, :maj_minor, :date, :release_notes
24
-
25
- def initialize(version, date, type)
26
- @version = version
27
- @maj_minor = version.split(".")[0..1].join(".")
28
- @date = Date.parse(date) unless date.nil?
29
- @release_notes = release_notes_from_file
30
- @type = type
31
- end
32
-
33
- def render
34
- puts "-" * 30
35
- puts ERB.new(template_for(@type)).result(binding)
36
- puts "-" * 30
37
- end
38
-
39
- def template_for(type)
40
- File.read("tasks/templates/#{type}.md.erb")
41
- end
42
-
43
- def release_notes_from_file
44
- File.read("RELEASE_NOTES.md").match(/^# Chef Infra Client Release Notes #{@maj_minor}:\n\n(.*)/m)[1]
45
- end
46
- end
47
-
48
- desc "Generate the Release Announcement (version: X.Y.Z)"
49
- task :announce_release, :version do |t, args|
50
- ReleaseAnnouncement.new(args[:version], nil, "release").render
51
- end
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # This script helps to test external gems in the content of the current
4
- # Chef install. We want to make sure that the external gems will still function
5
- # once we release Chef so we run *their* specs against the current contents
6
- # of the chef / ohai repos. It let's us know if we need to update downstream
7
- # gems or fix regressions in chef *before* we release.
8
-
9
- $:.unshift(File.expand_path("../../lib", File.dirname(__FILE__)))
10
-
11
- require "tmpdir"
12
- require "bundler"
13
- require "chef/mixin/shell_out"
14
-
15
- include Chef::Mixin::ShellOut
16
-
17
- github_repo = ARGV.shift
18
- git_thing = ARGV.shift
19
-
20
- build_dir = Dir.pwd
21
-
22
- env = {
23
- "GEMFILE_MOD" => "gem 'chef', path: '#{build_dir}'; " \
24
- "gem 'ohai', git: 'https://github.com/chef/ohai.git'",
25
- "CHEF_LICENSE" => "accept-no-persist",
26
- }
27
-
28
- Dir.mktmpdir("chef-external-test") do |dir|
29
- git_url = "https://github.com/#{github_repo}"
30
- Dir.rmdir dir
31
- shell_out!("git clone #{git_url} #{dir}", live_stream: STDOUT)
32
- Dir.chdir(dir) do
33
- shell_out!("git checkout #{git_thing}", live_stream: STDOUT)
34
- Bundler.with_clean_env do
35
- shell_out!("bundle install", live_stream: STDOUT, env: env)
36
- shell_out!("bundle exec #{ARGV.join(" ")}", live_stream: STDOUT, env: env)
37
- end
38
- end
39
- end
@@ -1,58 +0,0 @@
1
- #
2
- # Copyright:: Copyright (c) 2016-2018, Chef Software Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require "bundler"
19
-
20
- desc "Tasks to update and check dependencies"
21
- namespace :dependencies do
22
-
23
- # Update all dependencies to the latest constraint-matching version
24
- desc "Update all dependencies."
25
- task update: %w{
26
- dependencies:update_gemfile_lock
27
- dependencies:update_omnibus_gemfile_lock
28
- }
29
-
30
- def bundle_update_locked_multiplatform_task(task_name, dir)
31
- desc "Update #{dir}/Gemfile.lock."
32
- task task_name do
33
- Dir.chdir(dir) do
34
- Bundler.with_clean_env do
35
- rm_f "#{dir}/Gemfile.lock"
36
- sh "bundle lock --update --add-platform ruby"
37
- sh "bundle lock --update --add-platform x64-mingw32"
38
- sh "bundle lock --update --add-platform x86-mingw32"
39
- end
40
- end
41
- end
42
- end
43
-
44
- def bundle_update_task(task_name, dir)
45
- desc "Update #{dir}/Gemfile.lock."
46
- task task_name do
47
- Dir.chdir(dir) do
48
- Bundler.with_clean_env do
49
- sh "bundle update"
50
- end
51
- end
52
- end
53
- end
54
-
55
- bundle_update_locked_multiplatform_task :update_gemfile_lock, "."
56
- bundle_update_locked_multiplatform_task :update_omnibus_gemfile_lock, "omnibus"
57
-
58
- end
@@ -1,369 +0,0 @@
1
- namespace :docs_site do
2
-
3
- desc "Generate resource documentation .rst pages in a docs_site directory"
4
-
5
- task :resources do
6
- Encoding.default_external = Encoding::UTF_8
7
-
8
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
9
-
10
- require "chef/resource_inspector"
11
- require "erb"
12
- require "fileutils"
13
-
14
- # @param version String
15
- # @return String Chef Infra Client or Chef Client depending on version
16
- def branded_chef_client_name(version)
17
- return "Chef Infra Client" if Gem::Version.new(version) >= Gem::Version.new("15")
18
-
19
- "Chef Client"
20
- end
21
-
22
- # @return [String, nil] a pretty defaul value string or nil if we want to skip it
23
- def pretty_default(default)
24
- return nil if default.nil? || default == "" || default == "lazy default"
25
-
26
- if default.is_a?(String)
27
-
28
- # .inspect wraps the value in quotes which we want for strings, but not sentences or symbols as strings
29
- return default.inspect unless default[0] == ":" || default.end_with?('.')
30
- end
31
- default
32
- end
33
-
34
- # generate the top example resource block example text
35
- # @param properties Array<Hash>
36
- # @return String
37
- def generate_resource_block(resource_name, properties)
38
- padding_size = largest_property_name(properties) + 6
39
-
40
- # build the resource string with property spacing between property names and comments
41
- text = " #{resource_name} 'name' do\n"
42
- properties.each do |p|
43
- text << " #{p["name"].ljust(padding_size)}"
44
- text << friendly_types_list(p["is"])
45
- text << " # default value: 'name' unless specified" if p["name_property"]
46
- text << " # default value: #{pretty_default(p["default"])}" unless pretty_default(p["default"]).nil?
47
- text << "\n"
48
- end
49
- text << " #{"action".ljust(padding_size)}Symbol # defaults to :#{@default_action.first} if not specified\n"
50
- text << " end"
51
- text
52
- end
53
-
54
- # we need to know how much space to leave so columns line up
55
- # @return String
56
- def largest_property_name(properties)
57
- if properties.empty?
58
- 6 # we'll include "action" even without properties and it's 6 chars long
59
- else
60
- properties.max_by { |x| x["name"].size }["name"].size
61
- end
62
- end
63
-
64
- # given an array of properties print out a single comma separated string
65
- # handling commas / and properly and plural vs. singular wording depending
66
- # on the number of properties
67
- # @return String
68
- def friendly_properly_list(arr)
69
- return nil if arr.empty? # resources w/o properties
70
-
71
- props = arr.map { |x| "``#{x["name"]}``" }
72
-
73
- # build the text string containing all properties bolded w/ punctuation
74
- if props.size > 1
75
- props[-1] = "and #{props[-1]}"
76
- end
77
- text = props.size == 2 ? props.join(" ") : props.join(", ")
78
- text << ( props.size > 1 ? " are the properties" : " is the property" )
79
- text << " available to this resource."
80
- text
81
- end
82
-
83
- # given an array of types print out a single comma separated string
84
- # handling a nil value that needs to be printed as "nil" and TrueClass/FalseClass
85
- # which needs to be "true" and "false"
86
- # @return String
87
- def friendly_types_list(arr)
88
- fixed_arr = Array(arr).map do |x|
89
- case x
90
- when "TrueClass"
91
- "true"
92
- when "FalseClass"
93
- "false"
94
- else
95
- x
96
- end
97
- end
98
- fixed_arr.compact.join(", ")
99
- end
100
-
101
- # Makes sure the resource name is bolded within the description
102
- # @return String
103
- def bolded_description(name, description)
104
- return nil if description.nil? # handle resources missing descriptions
105
-
106
- # we only want to bold occurences of the resource name in the first 5 words so treat it as an array
107
- desc_array = description.split(" ")
108
-
109
- desc_array = desc_array[0..4].map! { |x| name == x ? "**#{x}**" : x } + desc_array[5..-1]
110
-
111
- # strip out notes and return just the description
112
- desc_array.join(" ").split("Note: ").first.strip
113
- end
114
-
115
- def note_text(description)
116
- return nil if description.nil?
117
-
118
- note = description.split("Note: ")[1]
119
- if note
120
- <<-HEREDOC
121
-
122
- .. note::
123
-
124
- #{note}
125
- HEREDOC
126
- end
127
- end
128
-
129
- def boilerplate_content
130
- <<~HEREDOC
131
- Common Resource Functionality
132
- =====================================================
133
-
134
- Chef resources include common properties, notifications, and resource guards.
135
-
136
- Common Properties
137
- -----------------------------------------------------
138
-
139
- .. tag resources_common_properties
140
-
141
- The following properties are common to every resource:
142
-
143
- ``ignore_failure``
144
- **Ruby Type:** true, false | **Default Value:** ``false``
145
-
146
- Continue running a recipe if a resource fails for any reason.
147
-
148
- ``retries``
149
- **Ruby Type:** Integer | **Default Value:** ``0``
150
-
151
- The number of attempts to catch exceptions and retry the resource.
152
-
153
- ``retry_delay``
154
- **Ruby Type:** Integer | **Default Value:** ``2``
155
-
156
- The retry delay (in seconds).
157
-
158
- ``sensitive``
159
- **Ruby Type:** true, false | **Default Value:** ``false``
160
-
161
- Ensure that sensitive resource data is not logged by Chef Infra Client.
162
-
163
- .. end_tag
164
-
165
- Notifications
166
- -----------------------------------------------------
167
-
168
- ``notifies``
169
- **Ruby Type:** Symbol, 'Chef::Resource[String]'
170
-
171
- .. tag resources_common_notification_notifies
172
-
173
- A resource may notify another resource to take action when its state changes. Specify a ``'resource[name]'``, the ``:action`` that resource should take, and then the ``:timer`` for that action. A resource may notify more than one resource; use a ``notifies`` statement for each resource to be notified.
174
-
175
- .. end_tag
176
-
177
- .. tag resources_common_notification_timers
178
-
179
- A timer specifies the point during a Chef Infra Client run at which a notification is run. The following timers are available:
180
-
181
- ``:before``
182
- Specifies that the action on a notified resource should be run before processing the resource block in which the notification is located.
183
-
184
- ``:delayed``
185
- Default. Specifies that a notification should be queued up, and then executed at the end of a Chef Infra Client run.
186
-
187
- ``:immediate``, ``:immediately``
188
- Specifies that a notification should be run immediately, per resource notified.
189
-
190
- .. end_tag
191
-
192
- .. tag resources_common_notification_notifies_syntax
193
-
194
- The syntax for ``notifies`` is:
195
-
196
- .. code-block:: ruby
197
-
198
- notifies :action, 'resource[name]', :timer
199
-
200
- .. end_tag
201
-
202
- ``subscribes``
203
- **Ruby Type:** Symbol, 'Chef::Resource[String]'
204
-
205
- .. tag resources_common_notification_subscribes
206
-
207
- A resource may listen to another resource, and then take action if the state of the resource being listened to changes. Specify a ``'resource[name]'``, the ``:action`` to be taken, and then the ``:timer`` for that action.
208
-
209
- Note that ``subscribes`` does not apply the specified action to the resource that it listens to - for example:
210
-
211
- .. code-block:: ruby
212
-
213
- file '/etc/nginx/ssl/example.crt' do
214
- mode '0600'
215
- owner 'root'
216
- end
217
-
218
- service 'nginx' do
219
- subscribes :reload, 'file[/etc/nginx/ssl/example.crt]', :immediately
220
- end
221
-
222
- In this case the ``subscribes`` property reloads the ``nginx`` service whenever its certificate file, located under ``/etc/nginx/ssl/example.crt``, is updated. ``subscribes`` does not make any changes to the certificate file itself, it merely listens for a change to the file, and executes the ``:reload`` action for its resource (in this example ``nginx``) when a change is detected.
223
-
224
- .. end_tag
225
-
226
- .. tag resources_common_notification_timers
227
-
228
- A timer specifies the point during a Chef Infra Client run at which a notification is run. The following timers are available:
229
-
230
- ``:before``
231
- Specifies that the action on a notified resource should be run before processing the resource block in which the notification is located.
232
-
233
- ``:delayed``
234
- Default. Specifies that a notification should be queued up, and then executed at the end of a Chef Infra Client run.
235
-
236
- ``:immediate``, ``:immediately``
237
- Specifies that a notification should be run immediately, per resource notified.
238
-
239
- .. end_tag
240
-
241
- .. tag resources_common_notification_subscribes_syntax
242
-
243
- The syntax for ``subscribes`` is:
244
-
245
- .. code-block:: ruby
246
-
247
- subscribes :action, 'resource[name]', :timer
248
-
249
- .. end_tag
250
-
251
- Guards
252
- -----------------------------------------------------
253
-
254
- .. tag resources_common_guards
255
-
256
- A guard property can be used to evaluate the state of a node during the execution phase of a Chef Infra Client run. Based on the results of this evaluation, a guard property is then used to tell Chef Infra Client if it should continue executing a resource. A guard property accepts either a string value or a Ruby block value:
257
-
258
- * A string is executed as a shell command. If the command returns ``0``, the guard is applied. If the command returns any other value, then the guard property is not applied. String guards in a **powershell_script** run Windows PowerShell commands and may return ``true`` in addition to ``0``.
259
- * A block is executed as Ruby code that must return either ``true`` or ``false``. If the block returns ``true``, the guard property is applied. If the block returns ``false``, the guard property is not applied.
260
-
261
- A guard property is useful for ensuring that a resource is idempotent by allowing that resource to test for the desired state as it is being executed, and then if the desired state is present, for Chef Infra Client to do nothing.
262
-
263
- .. end_tag
264
-
265
- **Properties**
266
-
267
- .. tag resources_common_guards_properties
268
-
269
- The following properties can be used to define a guard that is evaluated during the execution phase of a Chef Infra Client run:
270
-
271
- ``not_if``
272
- Prevent a resource from executing when the condition returns ``true``.
273
-
274
- ``only_if``
275
- Allow a resource to execute only if the condition returns ``true``.
276
-
277
- .. end_tag
278
- HEREDOC
279
- end
280
-
281
- template = %{=====================================================
282
- <%= @name %> resource
283
- =====================================================
284
- `[edit on GitHub] <https://github.com/chef/chef-web-docs/blob/master/chef_master/source/resource_<%= @name %>.rst>`__
285
-
286
- <%= bolded_description(@name, @description) %>
287
- <%= note_text(@description) -%>
288
- <% unless @introduced.nil? -%>
289
-
290
- **New in <%= branded_chef_client_name(@introduced) %> <%= @introduced %>.**
291
- <% end -%>
292
-
293
- Syntax
294
- =====================================================
295
-
296
- The <%= @name %> resource has the following syntax:
297
-
298
- .. code-block:: ruby
299
-
300
- <%= @resource_block %>
301
-
302
- where:
303
-
304
- * ``<%= @name %>`` is the resource.
305
- * ``name`` is the name given to the resource block.
306
- * ``action`` identifies which steps Chef Infra Client will take to bring the node into the desired state.
307
- <% unless @property_list.nil? %>* <%= @property_list %><% end %>
308
-
309
- Actions
310
- =====================================================
311
-
312
- The <%= @name %> resource has the following actions:
313
- <% @actions.each do |a| %>
314
- ``:<%= a %>``
315
- <% if a == @default_action %>Default. <% end %>Description here.
316
- <% end %>
317
- ``:nothing``
318
- .. tag resources_common_actions_nothing
319
-
320
- This resource block does not act unless notified by another resource to take action. Once notified, this resource block either runs immediately or is queued up to run at the end of a Chef Infra Client run.
321
-
322
- .. end_tag
323
-
324
- Properties
325
- =====================================================
326
-
327
- The <%= @name %> resource has the following properties:
328
- <% @properties.each do |p| %>
329
- ``<%= p['name'] %>``
330
- **Ruby Type:** <%= friendly_types_list(p['is']) %><% unless pretty_default(p['default']).nil? %> | **Default Value:** ``<%= pretty_default(p['default']) %>``<% end %><% if p['required'] %> | ``REQUIRED``<% end %><% if p['deprecated'] %> | ``DEPRECATED``<% end %><% if p['name_property'] %> | **Default Value:** ``The resource block's name``<% end %>
331
-
332
- <% unless p['description'].nil? %> <%= p['description'].strip %><% end %>
333
- <% unless p['introduced'].nil? -%>\n\n *New in <%= branded_chef_client_name(p['introduced']) %> <%= p['introduced'] -%>.*\n<% end -%>
334
- <% end %>
335
- <% if @properties.empty? %>This resource does not have any properties.\n<% end -%>
336
- <%= boilerplate_content %>
337
- Examples
338
- =====================================================
339
-
340
- The following examples demonstrate various approaches for using resources in recipes:
341
-
342
- <%= @examples -%>
343
- }
344
-
345
- FileUtils.mkdir_p "docs_site"
346
- resources = Chef::JSONCompat.parse(ResourceInspector.inspect)
347
- resources.each do |resource, data|
348
- next if ["scm", "whyrun_safe_ruby_block", "l_w_r_p_base", "user_resource_abstract_base_class", "linux_user", "pw_user", "aix_user", "dscl_user", "solaris_user", "windows_user", ""].include?(resource)
349
-
350
- puts "Writing out #{resource}."
351
- @name = resource
352
- @description = data["description"]
353
- @default_action = data["default_action"]
354
- @actions = (data["actions"] - ["nothing"]).sort
355
- @examples = data["examples"]
356
- @introduced = data["introduced"]
357
- @preview = data["preview"]
358
- @properties = data["properties"].reject { |v| v["name"] == "name" }.sort_by! { |v| v["name"] }
359
- @resource_block = generate_resource_block(resource, @properties)
360
- @property_list = friendly_properly_list(@properties)
361
- @examples = data["examples"]
362
-
363
- t = ERB.new(template, nil, "-")
364
- File.open("docs_site/resource_#{@name}.rst", "w") do |f|
365
- f.write t.result(binding)
366
- end
367
- end
368
- end
369
- end
@@ -1,34 +0,0 @@
1
- Ohai Chefs!
2
-
3
- We're happy to announce the release of Chef v<%= @maj_minor %>!
4
-
5
- # Release Highlights
6
-
7
- <%= @release_notes %>
8
-
9
- Please see the [CHANGELOG](https://github.com/chef/chef/blob/master/CHANGELOG.md) for the complete list of changes.
10
-
11
- # Get the Build
12
- As always, you can download binaries directly from [downloads.chef.io](https://downloads.chef.io/chef/<%= @version %>) or by using the `mixlib-install` command line utility:
13
-
14
- ```shell
15
- $ mixlib-install download chef -v <%= @version %>
16
- ```
17
-
18
- Alternatively, you can install Chef using one of the following command options:
19
-
20
- ```shell
21
- # In Shell
22
- $ curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chef -v <%= @version %>
23
-
24
- # In Windows Powershell
25
- . { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -project chef -version <%= @version %>
26
- ```
27
-
28
- If you want to give this version a spin in Test Kitchen, create or add the following to your `kitchen.yml` file:
29
-
30
- ```yaml
31
- provisioner:
32
- product_name: chef
33
- product_version: <%= @version %>
34
- ```