From 66628e87287353fb04c7750e86b9fb4ccb80c9f8 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 1 Aug 2017 06:21:45 -0700 Subject: [PATCH] Testing updates + Oracle / Amazon / openSUSE support (#91) * Enable all foodcritic rules * Use dokken images in kitchen dokken config * Update platforms in the kitchen config * Test with the latest ChefDK and relative paths * Update the Fedora name in Travis * Remove support for Fedora < 18 * Add Oracle Support * Remove support for Ubuntu <= 9.10 * Add support for Amazon Linux on Chef 13 * Fix resource deprecation warnings * Use more modern fauxhai platforms * Remove Ubuntu 14.10 support * Add Amazon Linux to the readme * Remove the autoeject test and test amazon in Travis * Support and test the latest opensuse release Signed-off-by: Tim Smith --- .foodcritic | 2 - .kitchen.dokken.yml | 49 +++++++++---------- .kitchen.yml | 12 ++--- .travis.yml | 33 +++++++------ CHANGELOG.md | 10 ++++ README.md | 4 +- libraries/helpers_param.rb | 15 +++--- libraries/sysctl_param.rb | 16 +++--- metadata.rb | 4 +- spec/restart_false_spec.rb | 6 +-- spec/sysctl_test/attributes_spec.rb | 6 --- spec/sysctl_test/resources_spec.rb | 6 --- .../sysctl_test/attributes/default.rb | 1 - .../sysctl_test/recipes/resources.rb | 4 -- .../inspec/assert_functioning_spec.rb | 10 ---- .../inspec/assert_functioning_spec.rb | 10 ---- 16 files changed, 81 insertions(+), 107 deletions(-) delete mode 100644 .foodcritic diff --git a/.foodcritic b/.foodcritic deleted file mode 100644 index cb1a7b0..0000000 --- a/.foodcritic +++ /dev/null @@ -1,2 +0,0 @@ -~FC059 -~FC085 diff --git a/.kitchen.dokken.yml b/.kitchen.dokken.yml index a38e10f..0a1a707 100644 --- a/.kitchen.dokken.yml +++ b/.kitchen.dokken.yml @@ -1,76 +1,75 @@ driver: name: dokken privileged: true # because Docker and SystemD/Upstart - chef_version: current + chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> transport: name: dokken provisioner: name: dokken + deprecations_as_errors: true verifier: name: inspec platforms: +- name: amazonlinux + driver: + image: dokken/amazonlinux + pid_one_command: /sbin/init + - name: debian-7 driver: - image: debian:7 + image: dokken/debian-7 pid_one_command: /sbin/init intermediate_instructions: - RUN /usr/bin/apt-get update - - RUN /usr/bin/apt-get install apt-transport-https lsb-release procps net-tools -y - name: debian-8 driver: - image: debian:8 + image: dokken/debian-8 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + +- name: debian-9 + driver: + image: dokken/debian-9 pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update - - RUN /usr/bin/apt-get install apt-transport-https lsb-release procps net-tools -y - name: centos-6 driver: - image: centos:6 - platform: rhel + image: dokken/centos-6 pid_one_command: /sbin/init - intermediate_instructions: - - RUN yum -y install lsof which initscripts net-tools wget net-tools - name: centos-7 driver: - image: centos:7 - platform: rhel + image: dokken/centos-7 pid_one_command: /usr/lib/systemd/systemd - intermediate_instructions: - - RUN yum -y install lsof which systemd-sysv initscripts wget net-tools -- name: fedora-25 +- name: fedora-latest driver: - image: fedora:latest + image: dokken/fedora-latest pid_one_command: /usr/lib/systemd/systemd - intermediate_instructions: - - RUN dnf -y install yum which systemd-sysv initscripts wget net-tools - name: ubuntu-14.04 driver: - image: ubuntu-upstart:14.04 + image: dokken/ubuntu-14.04 pid_one_command: /sbin/init intermediate_instructions: - RUN /usr/bin/apt-get update - - RUN /usr/bin/apt-get install apt-transport-https lsb-release procps net-tools -y - name: ubuntu-16.04 driver: - image: ubuntu:16.04 + image: dokken/ubuntu-16.04 pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update - - RUN /usr/bin/apt-get install apt-transport-https lsb-release procps net-tools -y - name: opensuse-leap driver: - image: opensuse:leap - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN zypper --non-interactive install aaa_base perl-Getopt-Long-Descriptive which net-tools + image: dokken/opensuse-leap + pid_one_command: /bin/systemd \ No newline at end of file diff --git a/.kitchen.yml b/.kitchen.yml index 6307d8a..64fa611 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,23 +1,23 @@ ---- driver: name: vagrant - chef_version: current provisioner: name: chef_zero data_bags_path: "data_bags" + deprecations_as_errors: true verifier: name: inspec -client_rb: - treat_deprecation_warnings_as_errors: true - platforms: +- name: amazon-linux + driver_config: + box: mvbcoding/awslinux - name: centos-6.9 - name: centos-7.3 - name: debian-7.11 -- name: debian-8.7 +- name: debian-8.8 +- name: debian-9.0 - name: fedora-25 - name: freebsd-11.0 - name: opensuse-leap-42.2 diff --git a/.travis.yml b/.travis.yml index 4ce76b4..41c672b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ dist: trusty addons: apt: sources: - - chef-stable-trusty + - chef-current-trusty packages: - chefdk @@ -19,33 +19,36 @@ services: docker env: matrix: - - INSTANCE=resources-debian-7 - - INSTANCE=resources-debian-8 + - INSTANCE=resources-amazonlinux - INSTANCE=resources-centos-6 - INSTANCE=resources-centos-7 - - INSTANCE=resources-fedora-25 + - INSTANCE=resources-debian-7 + - INSTANCE=resources-debian-8 + - INSTANCE=resources-fedora-latest + - INSTANCE=resources-ubuntu-1404 - INSTANCE=resources-ubuntu-1604 - # - INSTANCE=resources-opensuse-leap - - INSTANCE=attributes-debian-7 - - INSTANCE=attributes-debian-8 + - INSTANCE=resources-opensuse-leap + - INSTANCE=attributes-amazonlinux - INSTANCE=attributes-centos-6 - INSTANCE=attributes-centos-7 - - INSTANCE=attributes-fedora-25 + - INSTANCE=attributes-debian-7 + - INSTANCE=attributes-debian-8 + - INSTANCE=attributes-fedora-latest - INSTANCE=attributes-ubuntu-1404 - INSTANCE=attributes-ubuntu-1604 - # - INSTANCE=attributes-opensuse-leap + - INSTANCE=attributes-opensuse-leap before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - eval "$(/opt/chefdk/bin/chef shell-init bash)" - - /opt/chefdk/embedded/bin/chef --version - - /opt/chefdk/embedded/bin/cookstyle --version - - /opt/chefdk/embedded/bin/foodcritic --version + - eval "$(chef shell-init bash)" + - chef --version + - cookstyle --version + - foodcritic --version -script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE} +script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml kitchen verify ${INSTANCE} matrix: include: - script: - - /opt/chefdk/bin/chef exec delivery local all + - chef exec delivery local all env: UNIT_AND_LINT=1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 40782ea..fd457da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Sysctl +## v0.10.0 (2017-07-31) + +- Added support for Amazon Linux, Oracle Linux, and openSUSE +- Removed support for Ubuntu 14.10, Ubuntu <= 9.10, and Fedora < 18 +- Resolved CHEF-19 Deprecation warnings that will impact Chef 14 runs +- Expanded Travis testing to more platforms and releases +- Removed problematic cdrom autoeject test that didn't work on all platforms +- Reenabled testing of FoodCritic rules FC059 and FC085 +- Enabled testing of Chef deprecation warnings + ## v0.9.0 (2017-05-18) - This cookbook is now maintained by Sous-Chefs. See diff --git a/README.md b/README.md index e2dd460..d163fcb 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,14 @@ Set [sysctl](http://en.wikipedia.org/wiki/Sysctl) system control parameters via ### Platforms +- Amazon Linux (Integration tested) - Debian/Ubuntu (Integration tested) - RHEL/CentOS (Integration tested) +- openSUSE (Integration tested) - PLD Linux - Exherbo - Arch Linux -- openSUSE +- SLES - FreeBSD ### Chef diff --git a/libraries/helpers_param.rb b/libraries/helpers_param.rb index 30d9293..a8ab128 100644 --- a/libraries/helpers_param.rb +++ b/libraries/helpers_param.rb @@ -9,7 +9,7 @@ def sysctld? case node['platform_family'] when 'freebsd' false - when 'arch', 'debian', 'rhel', 'fedora' + when 'arch', 'debian', 'rhel', 'fedora', 'amazon' true when 'suse' node['platform_version'].to_f < 12.0 ? false : true @@ -97,24 +97,21 @@ def service_type when 'arch', 'exherbo' s['name'] = 'systemd-sysctl' s['provider'] = Chef::Provider::Service::Systemd - when 'centos', 'redhat', 'scientific' + when 'centos', 'redhat', 'scientific', 'oracle' if node['platform_version'].to_f >= 7.0 s['name'] = 'systemd-sysctl' s['provider'] = Chef::Provider::Service::Systemd end when 'fedora' - if node['platform_version'].to_f >= 18 - s['name'] = 'systemd-sysctl' - s['provider'] = Chef::Provider::Service::Systemd - end + s['name'] = 'systemd-sysctl' + s['provider'] = Chef::Provider::Service::Systemd when 'ubuntu' - if node['platform_version'].to_f >= 9.10 && node['platform_version'].to_f < 15.04 - s['name'] = 'procps-instance' if node['platform_version'].to_f >= 14.10 + if node['platform_version'].to_f < 15.04 s['provider'] = Chef::Provider::Service::Upstart elsif node['platform_version'].to_f >= 15.04 s['provider'] = Chef::Provider::Service::Init::Systemd end - when 'suse' + when 'suse', 'opensuseleap' if node['platform_version'].to_f < 12.0 s['name'] = 'boot.sysctl' elsif node['platform_version'].to_f >= 12.0 diff --git a/libraries/sysctl_param.rb b/libraries/sysctl_param.rb index 0567e83..de1ebcf 100644 --- a/libraries/sysctl_param.rb +++ b/libraries/sysctl_param.rb @@ -28,7 +28,7 @@ def create_init cookbook 'sysctl' source 'procps.init-rhel.erb' mode '0775' - only_if { platform_family?('rhel', 'fedora', 'pld') } + only_if { platform_family?('rhel', 'fedora', 'pld', 'amazon') } end s = service_type @@ -62,20 +62,20 @@ def create_sysctld(key, value) action :apply do converge_if_changed do - node.default['sysctl']['backup'][key] ||= get_sysctl_value(key) + node.default['sysctl']['backup'][new_resource.key] ||= get_sysctl_value(new_resource.key) create_init - create_sysctld(key, value) - set_sysctl_param(key, value) + create_sysctld(new_resource.key, new_resource.value) + set_sysctl_param(new_resource.key, new_resource.value) end end action :remove do - converge_by "reverting #{key}" do - v = node['sysctl']['backup'][key] + converge_by "reverting #{new_resource.key}" do + v = node['sysctl']['backup'][new_resource.key] r = create_sysctld r.action(:delete) - set_sysctl_param(key, v) - node.rm['sysctl']['backup'][key] + set_sysctl_param(new_resource.key, v) + node.rm['sysctl']['backup'][new_resource.key] end end end diff --git a/metadata.rb b/metadata.rb index 80a86b7..4a8e901 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,14 +6,16 @@ license 'Apache-2.0' description 'Configures sysctl parameters' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.9.0' +version '0.10.0' chef_version '>= 12.5' if respond_to?(:chef_version) +supports 'amazon' supports 'ubuntu', '>= 14.04' supports 'debian', '>= 7.0' supports 'centos', '>= 6.0' supports 'scientific', '>= 6.4' supports 'suse', '>= 11.0' +supports 'opensuseleap' supports 'redhat' supports 'pld' diff --git a/spec/restart_false_spec.rb b/spec/restart_false_spec.rb index dcf47d9..2b09622 100644 --- a/spec/restart_false_spec.rb +++ b/spec/restart_false_spec.rb @@ -5,10 +5,10 @@ describe 'sysctl::default' do platforms = { 'ubuntu' => ['14.04', '16.04'], - 'debian' => ['7.11', '8.7'], + 'debian' => ['7.11', '8.8'], 'fedora' => ['25'], - 'redhat' => ['6.8', '7.3'], - 'centos' => ['6.8', '7.3.1611'], + 'redhat' => ['6.9', '7.3'], + 'centos' => ['6.9', '7.3.1611'], 'freebsd' => ['10.3', '11.0'], 'suse' => ['12.2'], } diff --git a/spec/sysctl_test/attributes_spec.rb b/spec/sysctl_test/attributes_spec.rb index 8e768d2..b7177f5 100644 --- a/spec/sysctl_test/attributes_spec.rb +++ b/spec/sysctl_test/attributes_spec.rb @@ -9,11 +9,5 @@ value: '19' ) end - - it 'apply sysctl_param[dev.cdrom.autoeject]' do - expect(chef_run).to apply_sysctl_param('dev.cdrom.autoeject').with( - value: '1' - ) - end end end diff --git a/spec/sysctl_test/resources_spec.rb b/spec/sysctl_test/resources_spec.rb index 5c589bb..3e4f9e0 100644 --- a/spec/sysctl_test/resources_spec.rb +++ b/spec/sysctl_test/resources_spec.rb @@ -9,11 +9,5 @@ value: '19' ) end - - it 'apply sysctl_param[dev.cdrom.autoeject]' do - expect(chef_run).to apply_sysctl_param('dev.cdrom.autoeject').with( - value: '1' - ) - end end end diff --git a/test/cookbooks/sysctl_test/attributes/default.rb b/test/cookbooks/sysctl_test/attributes/default.rb index 05ef15e..619cd1e 100644 --- a/test/cookbooks/sysctl_test/attributes/default.rb +++ b/test/cookbooks/sysctl_test/attributes/default.rb @@ -1,2 +1 @@ default['sysctl']['params']['vm']['swappiness'] = 19 -default['sysctl']['params']['dev']['cdrom']['autoeject'] = '1' diff --git a/test/cookbooks/sysctl_test/recipes/resources.rb b/test/cookbooks/sysctl_test/recipes/resources.rb index b8ec329..34a2a6f 100644 --- a/test/cookbooks/sysctl_test/recipes/resources.rb +++ b/test/cookbooks/sysctl_test/recipes/resources.rb @@ -21,7 +21,3 @@ sysctl_param 'vm.swappiness' do value 19 end - -sysctl_param 'dev.cdrom.autoeject' do - value '1' -end diff --git a/test/integration/attributes/inspec/assert_functioning_spec.rb b/test/integration/attributes/inspec/assert_functioning_spec.rb index 91253c3..6091e7a 100644 --- a/test/integration/attributes/inspec/assert_functioning_spec.rb +++ b/test/integration/attributes/inspec/assert_functioning_spec.rb @@ -7,13 +7,3 @@ it { should be_file } its(:content) { should match /^vm.swappiness = 19$/ } end - -describe command('sysctl -n dev.cdrom.autoeject') do - its(:exit_status) { should eq 0 } - its(:stdout) { should match(/^1$/) } -end - -describe file('/etc/sysctl.d/99-chef-dev.cdrom.autoeject.conf') do - it { should be_file } - its(:content) { should match /^dev.cdrom.autoeject = 1$/ } -end diff --git a/test/integration/resources/inspec/assert_functioning_spec.rb b/test/integration/resources/inspec/assert_functioning_spec.rb index 91253c3..6091e7a 100644 --- a/test/integration/resources/inspec/assert_functioning_spec.rb +++ b/test/integration/resources/inspec/assert_functioning_spec.rb @@ -7,13 +7,3 @@ it { should be_file } its(:content) { should match /^vm.swappiness = 19$/ } end - -describe command('sysctl -n dev.cdrom.autoeject') do - its(:exit_status) { should eq 0 } - its(:stdout) { should match(/^1$/) } -end - -describe file('/etc/sysctl.d/99-chef-dev.cdrom.autoeject.conf') do - it { should be_file } - its(:content) { should match /^dev.cdrom.autoeject = 1$/ } -end