summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@chef.io>2020-05-04 16:21:44 -0700
committerGitHub <noreply@github.com>2020-05-04 16:21:44 -0700
commit14c5bb0e09acb64f845590eac90107ca23710ba1 (patch)
treebeedd216aca103f88bbc27a38af33d082d68835f
parentdd0e2dbb8b299157c9bf82c9ac7d7dd374b31ca7 (diff)
parentc8cb9344f59f4a9610e94c951b94593277ba825e (diff)
downloadchef-14c5bb0e09acb64f845590eac90107ca23710ba1.tar.gz
Merge pull request #9791 from chef/required_fixes
-rw-r--r--kitchen-tests/cookbooks/end_to_end/metadata.rb1
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_alternatives.rb (renamed from kitchen-tests/cookbooks/end_to_end/recipes/alternatives.rb)0
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb14
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_chef-vault.rb (renamed from kitchen-tests/cookbooks/end_to_end/recipes/chef-vault.rb)0
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_packages.rb (renamed from kitchen-tests/cookbooks/end_to_end/recipes/packages.rb)0
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb12
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_tests.rb (renamed from kitchen-tests/cookbooks/end_to_end/recipes/tests.rb)0
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/default.rb12
-rw-r--r--lib/chef/knife/environment_compare.rb2
-rw-r--r--lib/chef/knife/list.rb2
-rw-r--r--lib/chef/resource/apt_preference.rb4
-rw-r--r--lib/chef/resource/sysctl.rb61
12 files changed, 96 insertions, 12 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/metadata.rb b/kitchen-tests/cookbooks/end_to_end/metadata.rb
index 9394d16408..c0c36063ae 100644
--- a/kitchen-tests/cookbooks/end_to_end/metadata.rb
+++ b/kitchen-tests/cookbooks/end_to_end/metadata.rb
@@ -13,7 +13,6 @@ depends "ntp"
depends "openssh"
depends "resolver"
depends "selinux"
-depends "ubuntu"
depends "users"
depends "git"
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/alternatives.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_alternatives.rb
index 8e0a0bb178..8e0a0bb178 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/alternatives.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_alternatives.rb
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb
new file mode 100644
index 0000000000..6b492230f1
--- /dev/null
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb
@@ -0,0 +1,14 @@
+#
+# Cookbook:: end_to_end
+# Recipe:: apt_preference
+#
+
+apt_preference "dotdeb" do
+ glob "*"
+ pin "origin packages.dotdeb.org"
+ pin_priority "700"
+end
+
+apt_preference "libmysqlclient16" do
+ action :remove
+end \ No newline at end of file
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/chef-vault.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_chef-vault.rb
index aa01982e3d..aa01982e3d 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/chef-vault.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_chef-vault.rb
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/packages.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_packages.rb
index 58ede61f52..58ede61f52 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/packages.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_packages.rb
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb
new file mode 100644
index 0000000000..8c644e01c6
--- /dev/null
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb
@@ -0,0 +1,12 @@
+#
+# Cookbook:: end_to_end
+# Recipe:: sysctl
+#
+
+sysctl "vm.swappiness" do
+ value 19
+end
+
+sysctl "kernel.msgmax" do
+ action :remove
+end \ No newline at end of file
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/tests.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_tests.rb
index d74a310394..d74a310394 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/tests.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_tests.rb
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
index 54750039c5..494d48ec06 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
@@ -13,8 +13,6 @@ chef_sleep "2"
timezone "UTC"
-include_recipe "ubuntu" if platform?("ubuntu")
-
if platform_family?("rhel", "fedora", "amazon")
include_recipe "selinux::disabled"
end
@@ -40,7 +38,7 @@ build_essential do
raise_if_unsupported true
end
-include_recipe "::packages"
+include_recipe "::_packages"
include_recipe "ntp"
@@ -158,6 +156,8 @@ locale "set system locale" do
only_if { debian? }
end
-include_recipe "::chef-vault" unless includes_recipe?("end_to_end::chef-vault")
-include_recipe "::alternatives"
-include_recipe "::tests"
+include_recipe "::_chef-vault" unless includes_recipe?("end_to_end::chef-vault")
+include_recipe "::_sysctl"
+include_recipe "::_apt_preference"
+include_recipe "::_alternatives"
+include_recipe "::_tests"
diff --git a/lib/chef/knife/environment_compare.rb b/lib/chef/knife/environment_compare.rb
index 38e259a856..22abee59c8 100644
--- a/lib/chef/knife/environment_compare.rb
+++ b/lib/chef/knife/environment_compare.rb
@@ -81,7 +81,7 @@ class Chef
def constraint_list(environments)
constraints = {}
- environments.each do |env, url| # rubocop:disable Performance/HashEachMethods
+ environments.each do |env, url| # rubocop:disable Style/HashEachMethods
# Because you cannot modify the default environment I filter it out here.
unless env == "_default"
envdata = Chef::Environment.load(env)
diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb
index e5e196ecea..1cc398e01a 100644
--- a/lib/chef/knife/list.rb
+++ b/lib/chef/knife/list.rb
@@ -90,7 +90,7 @@ class Chef
# Flatten out directory results if necessary
if config[:flat]
- dir_results.each do |result, children| # rubocop:disable Performance/HashEachMethods
+ dir_results.each do |result, children| # rubocop:disable Style/HashEachMethods
results += children
end
dir_results = []
diff --git a/lib/chef/resource/apt_preference.rb b/lib/chef/resource/apt_preference.rb
index 7b5a56463c..fd987466ea 100644
--- a/lib/chef/resource/apt_preference.rb
+++ b/lib/chef/resource/apt_preference.rb
@@ -69,11 +69,11 @@ class Chef
property :pin, String,
description: "The package version or repository to pin.",
- required: true
+ required: [:add]
property :pin_priority, [String, Integer],
description: "Sets the Pin-Priority for a package. See <https://wiki.debian.org/AptPreferences> for more details.",
- required: true
+ required: [:add]
default_action :add
allowed_actions :add, :remove
diff --git a/lib/chef/resource/sysctl.rb b/lib/chef/resource/sysctl.rb
index c2ac8224b4..fcc82d09a2 100644
--- a/lib/chef/resource/sysctl.rb
+++ b/lib/chef/resource/sysctl.rb
@@ -30,6 +30,65 @@ class Chef
"Configuration files managed by this resource are named 99-chef-KEYNAME.conf. If"\
" an existing value was already set for the value it will be backed up to the node"\
" and restored if the :remove action is used later."
+ examples <<~DOC
+ **Set vm.swappiness**:
+
+ ```ruby
+ sysctl 'vm.swappiness' do
+ value 19
+ end
+ ```
+
+ **Remove kernel.msgmax**:
+
+ **Note**: This only removes the sysctl.d config for kernel.msgmax. The value will be set back to the kernel default value.
+
+ ```ruby
+ sysctl 'kernel.msgmax' do
+ action :remove
+ end
+ ```
+
+ **Adding Comments to sysctl configuration files**:
+
+ ```ruby
+ sysctl 'vm.swappiness' do
+ value 19
+ comment "define how aggressively the kernel will swap memory pages."
+ end
+ ```
+
+ This produces /etc/sysctl.d/99-chef-vm.swappiness.conf as follows:
+
+ ```
+ # define how aggressively the kernel will swap memory pages.
+ vm.swappiness = 1
+ ```
+
+ **Converting sysctl settings from shell scripts**:
+
+ Example of existing settings:
+
+ ```bash
+ fs.aio-max-nr = 1048576 net.ipv4.ip_local_port_range = 9000 65500 kernel.sem = 250 32000 100 128
+ ```
+
+ Converted to sysctl resources:
+
+ ```ruby
+ sysctl 'fs.aio-max-nr' do
+ value '1048576'
+ end
+
+ sysctl 'net.ipv4.ip_local_port_range' do
+ value '9000 65500'
+ end
+
+ sysctl 'kernel.sem' do
+ value '250 32000 100 128'
+ end
+ ```
+ DOC
introduced "14.0"
@@ -44,7 +103,7 @@ class Chef
property :value, [Array, String, Integer, Float],
description: "The value to set.",
coerce: proc { |v| coerce_value(v) },
- required: true
+ required: [:apply]
property :comment, [Array, String],
description: "Comments, placed above the resource setting in the generated file. For multi-line comments, use an array of strings, one per line.",