Skip to content

Commit

Permalink
Testing updates + Oracle / Amazon / openSUSE support (Sous-Chefs-Bone…
Browse files Browse the repository at this point in the history
…yard#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 <[email protected]>
  • Loading branch information
tas50 authored and damacus committed Aug 1, 2017
1 parent c2bde73 commit 66628e8
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 107 deletions.
2 changes: 0 additions & 2 deletions .foodcritic

This file was deleted.

49 changes: 24 additions & 25 deletions .kitchen.dokken.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 18 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dist: trusty
addons:
apt:
sources:
- chef-stable-trusty
- chef-current-trusty
packages:
- chefdk

Expand All @@ -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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 <http://sous-chefs.org/>
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 6 additions & 9 deletions libraries/helpers_param.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions libraries/sysctl_param.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 3 additions & 3 deletions spec/restart_false_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
}
Expand Down
6 changes: 0 additions & 6 deletions spec/sysctl_test/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 0 additions & 6 deletions spec/sysctl_test/resources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion test/cookbooks/sysctl_test/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
default['sysctl']['params']['vm']['swappiness'] = 19
default['sysctl']['params']['dev']['cdrom']['autoeject'] = '1'
4 changes: 0 additions & 4 deletions test/cookbooks/sysctl_test/recipes/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@
sysctl_param 'vm.swappiness' do
value 19
end

sysctl_param 'dev.cdrom.autoeject' do
value '1'
end
10 changes: 0 additions & 10 deletions test/integration/attributes/inspec/assert_functioning_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 0 additions & 10 deletions test/integration/resources/inspec/assert_functioning_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 66628e8

Please sign in to comment.