chef 16.2.44-universal-mingw32 → 16.2.50-universal-mingw32

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: 2a9c103ab2b384137278a132056b2566580ecba2d3942eb56eba020012e4bf97
4
- data.tar.gz: 5f91a5094cd595e1c2a67a71cff72595facf60ba7541452726970217fce9cf27
3
+ metadata.gz: 9e2aa147eefe9dffe9b65869ae839952018e04d68e94fa265da3adfdc15593b3
4
+ data.tar.gz: 44c6f2d935ae22f8577da356c0882c1dcc954d4f6827c88b8932d67bbaf3a3dd
5
5
  SHA512:
6
- metadata.gz: 6be5b314ba811bcec98ba9a14ce924ea0847253f7dfd7d50a95f6262058cb1ac0f3bb0646ce866647360ee65a1eccfce0c88ce3af6f248aae077ef2acaa557f3
7
- data.tar.gz: '069c49d69d1e6f79f5fa6f0dda745da26d20ab36cda607b4131624b893fb346e5688eb618036eaf96546b76bd93d11c54132fe00368e8dfe3e485f8e39b0930c'
6
+ metadata.gz: b313d3f74e5697c287c26592a8e3e523cf0e04532d203f1c191e116d091e16600611ab65048f3aec404bc28f4b9e2e156c06c918a4d218d14c21fd001546e21c
7
+ data.tar.gz: 05fcccaa38ec9ad1e82a0bcd1712e3287d3db3c3a045df85df16d82fb69c1c0401d4d6adeee57ccc801c14affdda2cd5df360889a49c22eec55b0cf9711f3eb1
@@ -33,17 +33,27 @@ class Chef
33
33
  end
34
34
 
35
35
  def run
36
+ credentials_data = self.class.config_loader.parse_credentials_file
36
37
  context_file = ChefConfig::PathHelper.home(".chef", "context").freeze
37
38
  profile = @name_args[0]&.strip
38
- if profile && !profile.empty?
39
+ if profile.nil? || profile.empty?
40
+ show_usage
41
+ ui.fatal("You must specify a profile")
42
+ exit 1
43
+ end
44
+
45
+ if credentials_data.nil? || credentials_data.empty?
46
+ ui.fatal("No profiles found, #{self.class.config_loader.credentials_file_path} does not exist or is empty")
47
+ exit 1
48
+ end
49
+
50
+ if credentials_data[profile].nil?
51
+ raise ChefConfig::ConfigurationError, "Profile #{profile} doesn't exist. Please add it to #{self.class.config_loader.credentials_file_path} and if it is profile with DNS name check that you are not missing single quotes around it as per docs https://docs.chef.io/workstation/knife_setup/#knife-profiles."
52
+ else
39
53
  # Ensure the .chef/ folder exists.
40
54
  FileUtils.mkdir_p(File.dirname(context_file))
41
55
  IO.write(context_file, "#{profile}\n")
42
56
  ui.msg("Set default profile to #{profile}")
43
- else
44
- show_usage
45
- ui.fatal("You must specify a profile")
46
- exit 1
47
57
  end
48
58
  end
49
59
 
@@ -89,7 +89,7 @@ class Chef
89
89
  description: "The path to the alternatives link."
90
90
 
91
91
  property :path, String,
92
- description: "The full path to the original application binary such as `/usr/bin/ruby27`."
92
+ description: "The absolute path to the original application binary such as `/usr/bin/ruby27`."
93
93
 
94
94
  property :priority, [String, Integer],
95
95
  coerce: proc { |n| n.to_i },
@@ -22,26 +22,59 @@ require_relative "../dist"
22
22
 
23
23
  class Chef
24
24
  class Resource
25
- # Use the chef_gem resource to install a gem only for the instance of Ruby that is dedicated to the chef-client.
26
- # When a gem is installed from a local file, it must be added to the node using the remote_file or cookbook_file
27
- # resources.
28
- #
29
- # The chef_gem resource works with all of the same properties and options as the gem_package resource, but does not
30
- # accept the gem_binary property because it always uses the CurrentGemEnvironment under which the chef-client is
31
- # running. In addition to performing actions similar to the gem_package resource, the chef_gem resource does the
32
- # following:
33
- # - Runs its actions immediately, before convergence, allowing a gem to be used in a recipe immediately after it is
34
- # installed
35
- # - Runs Gem.clear_paths after the action, ensuring that gem is aware of changes so that it can be required
36
- # immediately after it is installed
37
-
38
- require_relative "gem_package"
39
- require_relative "../dist"
40
-
41
25
  class ChefGem < Chef::Resource::Package::GemPackage
42
26
  unified_mode true
43
27
  provides :chef_gem
44
28
 
29
+ description <<~DESC
30
+ Use the **chef_gem** resource to install a gem only for the instance of Ruby that is dedicated to the #{Chef::Dist::CLIENT}.
31
+ When a gem is installed from a local file, it must be added to the node using the **remote_file** or **cookbook_file** resources.
32
+
33
+ The **chef_gem** resource works with all of the same properties and options as the **gem_package** resource, but does not
34
+ accept the `gem_binary` property because it always uses the `CurrentGemEnvironment` under which the `#{Chef::Dist::CLIENT}` is
35
+ running. In addition to performing actions similar to the **gem_package** resource, the **chef_gem** resource does the
36
+ following:
37
+ - Runs its actions immediately, before convergence, allowing a gem to be used in a recipe immediately after it is installed.
38
+ - Runs `Gem.clear_paths` after the action, ensuring that gem is aware of changes so that it can be required immediately after it is installed.
39
+
40
+ Warning: The **chef_gem** and **gem_package** resources are both used to install Ruby gems. For any machine on which #{Chef::Dist::PRODUCT} is
41
+ installed, there are two instances of Ruby. One is the standard, system-wide instance of Ruby and the other is a dedicated instance that is
42
+ available only to #{Chef::Dist::PRODUCT}.
43
+ Use the **chef_gem** resource to install gems into the instance of Ruby that is dedicated to #{Chef::Dist::PRODUCT}.
44
+ Use the **gem_package** resource to install all other gems (i.e. install gems system-wide).
45
+ DESC
46
+
47
+ examples <<~EXAMPLES
48
+ **Compile time vs. converge time installation of gems**
49
+
50
+ To install a gem while #{Chef::Dist::PRODUCT} is configuring the node (the converge phase), set the `compile_time` property to `false`:
51
+ ```ruby
52
+ chef_gem 'right_aws' do
53
+ compile_time false
54
+ action :install
55
+ end
56
+ ```
57
+
58
+ To install a gem while the resource collection is being built (the compile phase), set the `compile_time` property to `true`:
59
+ ```ruby
60
+ chef_gem 'right_aws' do
61
+ compile_time true
62
+ action :install
63
+ end
64
+ ```
65
+
66
+ Install MySQL for Chef
67
+ ```ruby
68
+ apt_update
69
+
70
+ build_essential 'install compilation tools' do
71
+ compile_time true
72
+ end
73
+
74
+ chef_gem 'mysql'
75
+ ```
76
+ EXAMPLES
77
+
45
78
  property :package_name, String,
46
79
  description: "An optional property to set the package name if it differs from the resource block's name.",
47
80
  identity: true
@@ -49,11 +82,14 @@ class Chef
49
82
  property :version, String,
50
83
  description: "The version of a package to be installed or upgraded."
51
84
 
52
- property :gem_binary, default: "#{RbConfig::CONFIG["bindir"]}/gem", default_description: "The `gem` binary included with #{Chef::Dist::PRODUCT}.",
53
- description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{Chef::Dist::PRODUCT} will be installed.",
54
- callbacks: {
55
- "The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments." => proc { |v| v == "#{RbConfig::CONFIG["bindir"]}/gem" },
56
- }
85
+ property :gem_binary, String,
86
+ default: "#{RbConfig::CONFIG["bindir"]}/gem",
87
+ default_description: "The `gem` binary included with #{Chef::Dist::PRODUCT}.",
88
+ description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{Chef::Dist::PRODUCT} will be used.",
89
+ callbacks: {
90
+ "The `chef_gem` resource is restricted to the current gem environment, use `gem_package` to install to other environments." =>
91
+ proc { |v| v == "#{RbConfig::CONFIG["bindir"]}/gem" },
92
+ }
57
93
  end
58
94
  end
59
95
  end
@@ -66,7 +66,7 @@ class Chef
66
66
  description: "The remote URL that is used to download the `.dmg` file, if specified."
67
67
 
68
68
  property :file, String,
69
- description: "The full path to the `.dmg` file on the local system."
69
+ description: "The absolute path to the `.dmg` file on the local system."
70
70
 
71
71
  property :owner, [String, Integer],
72
72
  description: "The user that should own the package installation."
@@ -25,7 +25,40 @@ class Chef
25
25
  unified_mode true
26
26
  provides :gem_package
27
27
 
28
- description "Use the **gem_package** resource to manage gem packages that are only included in recipes. When a package is installed from a local file, it must be added to the node using the remote_file or cookbook_file resources."
28
+ description <<~DESC
29
+ Use the **gem_package** resource to manage gem packages that are only included in recipes.
30
+ When a gem is installed from a local file, it must be added to the node using the **remote_file** or **cookbook_file** resources.
31
+
32
+ Note: The **gem_package** resource must be specified as `gem_package` and cannot be shortened to `package` in a recipe.
33
+
34
+ Warning: The **chef_gem** and **gem_package** resources are both used to install Ruby gems. For any machine on which #{Chef::Dist::PRODUCT} is
35
+ installed, there are two instances of Ruby. One is the standard, system-wide instance of Ruby and the other is a dedicated instance that is
36
+ available only to #{Chef::Dist::PRODUCT}.
37
+ Use the **chef_gem** resource to install gems into the instance of Ruby that is dedicated to #{Chef::Dist::PRODUCT}.
38
+ Use the **gem_package** resource to install all other gems (i.e. install gems system-wide).
39
+ DESC
40
+
41
+ examples <<~EXAMPLES
42
+ The following examples demonstrate various approaches for using the **gem_package** resource in recipes:
43
+
44
+ **Install a gem file from the local file system**
45
+
46
+ ```ruby
47
+ gem_package 'right_aws' do
48
+ source '/tmp/right_aws-1.11.0.gem'
49
+ action :install
50
+ end
51
+ ```
52
+
53
+ **Use the `ignore_failure` common attribute**
54
+
55
+ ```ruby
56
+ gem_package 'syntax' do
57
+ action :install
58
+ ignore_failure true
59
+ end
60
+ ```
61
+ EXAMPLES
29
62
 
30
63
  property :package_name, String,
31
64
  description: "An optional property to set the package name if it differs from the resource block's name.",
@@ -53,7 +86,7 @@ class Chef
53
86
  default: lazy { Chef::Config[:clear_gem_sources] }, desired_state: false
54
87
 
55
88
  property :gem_binary, String, desired_state: false,
56
- description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{Chef::Dist::PRODUCT} will be installed."
89
+ description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{Chef::Dist::PRODUCT} will be used."
57
90
 
58
91
  property :include_default_source, [ TrueClass, FalseClass, nil ],
59
92
  description: "Set to `false` to not include `Chef::Config[:rubygems_url]` in the sources.",
@@ -29,6 +29,21 @@ class Chef
29
29
 
30
30
  description "Use the **ssh_known_hosts_entry** resource to add an entry for the specified host in /etc/ssh/ssh_known_hosts or a user's known hosts file if specified."
31
31
  introduced "14.3"
32
+ examples <<~DOC
33
+ **Add a single entry for github.com with the key auto detected**
34
+
35
+ ```ruby
36
+ ssh_known_hosts_entry 'github.com'
37
+ ```
38
+
39
+ **Add a single entry with your own provided key**
40
+
41
+ ```ruby
42
+ ssh_known_hosts_entry 'github.com' do
43
+ key 'node.example.com ssh-rsa ...'
44
+ end
45
+ ```
46
+ DOC
32
47
 
33
48
  property :host, String,
34
49
  description: "The host to add to the known hosts file.",
@@ -34,6 +34,33 @@ class Chef
34
34
  " installation of the required sudo version. Chef-supported releases of Ubuntu, SuSE, Debian,"\
35
35
  " and RHEL (6+) all support this feature."
36
36
  introduced "14.0"
37
+ examples <<~DOC
38
+ **Grant a user sudo privileges for any command**
39
+
40
+ ```ruby
41
+ sudo 'admin' do
42
+ user 'admin'
43
+ end
44
+ ```
45
+
46
+ **Grant a user and groups sudo privileges for any command**
47
+
48
+ ```ruby
49
+ sudo 'admins' do
50
+ users 'bob'
51
+ groups 'sysadmins, superusers'
52
+ end
53
+ ```
54
+
55
+ **Grant passwordless sudo privileges for specific commands**
56
+
57
+ ```ruby
58
+ sudo 'passwordless-access' do
59
+ commands ['/bin/systemctl restart httpd', '/bin/systemctl restart mysql']
60
+ nopasswd true
61
+ end
62
+ ```
63
+ DOC
37
64
 
38
65
  # According to the sudo man pages sudo will ignore files in an include dir that have a `.` or `~`
39
66
  # We convert either to `__`
@@ -53,7 +80,7 @@ class Chef
53
80
  coerce: proc { |x| coerce_groups(x) }
54
81
 
55
82
  property :commands, Array,
56
- description: "An array of commands this sudoer can execute.",
83
+ description: "An array of full paths to commands this sudoer can execute.",
57
84
  default: ["ALL"]
58
85
 
59
86
  property :host, String,
@@ -112,7 +139,7 @@ class Chef
112
139
 
113
140
  # handle legacy cookbook property
114
141
  def after_created
115
- raise "The 'visudo_path' property from the sudo cookbook has been replaced with the 'visudo_binary' property. The path is now more intelligently determined and for most users specifying the path should no longer be necessary. If this resource still cannot determine the path to visudo then provide the full path to the binary with the 'visudo_binary' property." if visudo_path
142
+ raise "The 'visudo_path' property from the sudo cookbook has been replaced with the 'visudo_binary' property. The path is now more intelligently determined and for most users specifying the path should no longer be necessary. If this resource still cannot determine the path to visudo then provide the absolute path to the binary with the 'visudo_binary' property." if visudo_path
116
143
  end
117
144
 
118
145
  # VERY old legacy properties
@@ -26,6 +26,23 @@ class Chef
26
26
 
27
27
  description "Use the **swap_file** resource to create or delete swap files on Linux systems, and optionally to manage the swappiness configuration for a host."
28
28
  introduced "14.0"
29
+ examples <<~DOC
30
+ **Create a swap file**
31
+
32
+ ```ruby
33
+ swap_file '/dev/sda1' do
34
+ size 1024
35
+ end
36
+ ```
37
+
38
+ **Remove a swap file**
39
+
40
+ ```ruby
41
+ swap_file '/dev/sda1' do
42
+ action :remove
43
+ end
44
+ ```
45
+ DOC
29
46
 
30
47
  property :path, String,
31
48
  description: "The path where the swap file will be created on the system if it differs from the resource block's name.",
@@ -28,6 +28,21 @@ class Chef
28
28
 
29
29
  description "Use the **timezone** resource to change the system timezone on Windows, Linux, and macOS hosts. Timezones are specified in tz database format, with a complete list of available TZ values for Linux and macOS here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones and for Windows here: https://ss64.com/nt/timezones.html."
30
30
  introduced "14.6"
31
+ examples <<~DOC
32
+ **Set the timezone to UTC**
33
+
34
+ ```ruby
35
+ timezone 'UTC'
36
+ ```
37
+
38
+ **Set the timezone to UTC with a friendly resource name**
39
+
40
+ ```ruby
41
+ timezone 'Set the host's timezone to UTC' do
42
+ timezone 'UTC'
43
+ end
44
+ ```
45
+ DOC
31
46
 
32
47
  property :timezone, String,
33
48
  description: "An optional property to set the timezone value if it differs from the resource block's name.",
@@ -21,7 +21,7 @@ require_relative "../resource"
21
21
  class Chef
22
22
  class Resource
23
23
  class WindowsSecurityPolicy < Chef::Resource
24
- resource_name :windows_security_policy
24
+ provides :windows_security_policy
25
25
 
26
26
  # The valid policy_names options found here
27
27
  # https://github.com/ChrisAWalker/cSecurityOptions under 'AccountSettings'
@@ -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("16.2.44")
26
+ VERSION = Chef::VersionString.new("16.2.50")
27
27
  end
28
28
 
29
29
  #
@@ -30,6 +30,7 @@ describe "knife config use-profile", :workstation do
30
30
  knife("config", "use-profile", *cmd_args, instance_filter: lambda { |instance|
31
31
  # Fake the failsafe check because this command doesn't actually process knife.rb.
32
32
  $__KNIFE_INTEGRATION_FAILSAFE_CHECK << " ole"
33
+ allow(File).to receive(:file?).and_call_original
33
34
  })
34
35
  end
35
36
 
@@ -73,15 +74,56 @@ describe "knife config use-profile", :workstation do
73
74
 
74
75
  context "with an argument" do
75
76
  let(:cmd_args) { %w{production} }
77
+ before { file(".chef/credentials", <<~EOH) }
78
+ [production]
79
+ client_name = "testuser"
80
+ client_key = "testkey.pem"
81
+ chef_server_url = "https://example.com/organizations/testorg"
82
+ EOH
76
83
  it do
77
84
  is_expected.to eq "Set default profile to production\n"
78
85
  expect(File.read(path_to(".chef/context"))).to eq "production\n"
79
86
  end
80
87
  end
81
88
 
89
+ context "with no credentials file" do
90
+ let(:cmd_args) { %w{production} }
91
+ subject { knife_use_profile.stderr }
92
+ it { is_expected.to eq "FATAL: No profiles found, #{path_to(".chef/credentials")} does not exist or is empty\n" }
93
+ end
94
+
95
+ context "with an empty credentials file" do
96
+ let(:cmd_args) { %w{production} }
97
+ before { file(".chef/credentials", "") }
98
+ subject { knife_use_profile.stderr }
99
+ it { is_expected.to eq "FATAL: No profiles found, #{path_to(".chef/credentials")} does not exist or is empty\n" }
100
+ end
101
+
102
+ context "with an wrong argument" do
103
+ let(:cmd_args) { %w{staging} }
104
+ before { file(".chef/credentials", <<~EOH) }
105
+ [production]
106
+ client_name = "testuser"
107
+ client_key = "testkey.pem"
108
+ chef_server_url = "https://example.com/organizations/testorg"
109
+ EOH
110
+ subject { knife_use_profile }
111
+ it { expect { subject }.to raise_error ChefConfig::ConfigurationError, "Profile staging doesn't exist. Please add it to #{path_to(".chef/credentials")} and if it is profile with DNS name check that you are not missing single quotes around it as per docs https://docs.chef.io/workstation/knife_setup/#knife-profiles." }
112
+ end
113
+
82
114
  context "with $CHEF_HOME" do
83
115
  let(:cmd_args) { %w{staging} }
84
- before { ENV["CHEF_HOME"] = path_to("chefhome"); file("chefhome/tmp", "") }
116
+ before do
117
+ ENV["CHEF_HOME"] = path_to("chefhome"); file("chefhome/tmp", "")
118
+ file("chefhome/.chef/credentials", <<~EOH
119
+ [staging]
120
+ client_name = "testuser"
121
+ client_key = "testkey.pem"
122
+ chef_server_url = "https://example.com/organizations/testorg"
123
+ EOH
124
+ )
125
+ end
126
+
85
127
  it do
86
128
  is_expected.to eq "Set default profile to staging\n"
87
129
  expect(File.read(path_to("chefhome/.chef/context"))).to eq "staging\n"
@@ -91,7 +133,18 @@ describe "knife config use-profile", :workstation do
91
133
 
92
134
  context "with $KNIFE_HOME" do
93
135
  let(:cmd_args) { %w{development} }
94
- before { ENV["KNIFE_HOME"] = path_to("knifehome"); file("knifehome/tmp", "") }
136
+
137
+ before do
138
+ ENV["KNIFE_HOME"] = path_to("knifehome"); file("knifehome/tmp", "")
139
+ file("knifehome/.chef/credentials", <<~EOH
140
+ [development]
141
+ client_name = "testuser"
142
+ client_key = "testkey.pem"
143
+ chef_server_url = "https://example.com/organizations/testorg"
144
+ EOH
145
+ )
146
+ end
147
+
95
148
  it do
96
149
  is_expected.to eq "Set default profile to development\n"
97
150
  expect(File.read(path_to("knifehome/.chef/context"))).to eq "development\n"
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: 16.2.44
4
+ version: 16.2.50
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2020-06-23 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: 16.2.44
19
+ version: 16.2.50
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: 16.2.44
26
+ version: 16.2.50
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: 16.2.44
33
+ version: 16.2.50
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: 16.2.44
40
+ version: 16.2.50
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement