diff --git a/.kitchen.docker.yml b/.kitchen.docker.yml index 00ce4e2..a4bca60 100644 --- a/.kitchen.docker.yml +++ b/.kitchen.docker.yml @@ -1,28 +1,99 @@ -settings: - parallel: true - driver: - name: docker - # privileged is required otherwise the container doesn't boot right - privileged: true + name: dokken + chef_version: latest + privileged: true # because Docker and SystemD/Upstart + +transport: + name: dokken + +provisioner: + name: dokken + +verifier: + name: inspec platforms: +- name: debian-7 + driver: + image: debian:7 + pid_one_command: /sbin/init + intermediate_instructions: + - RUN /usr/bin/apt-get update + - RUN /usr/bin/apt-get install lsb-release procps -y + +- name: debian-8 + driver: + image: debian:8 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + - RUN /usr/bin/apt-get install lsb-release -y + +- name: centos-5 + driver: + image: centos:5 + platform: rhel + pid_one_command: /sbin/init + intermediate_instructions: + - RUN yum install -y which initscripts + +- name: centos-6 + driver: + image: centos:6 + platform: rhel + pid_one_command: /sbin/init + intermediate_instructions: + - RUN yum -y install which initscripts + - name: centos-7 driver: image: centos:7 platform: rhel - run_command: /usr/lib/systemd/systemd - provision_command: - - /bin/yum install -y initscripts net-tools wget + pid_one_command: /usr/lib/systemd/systemd + intermediate_instructions: + - RUN yum -y install lsof which systemd-sysv initscripts + +- name: fedora-latest + driver: + image: fedora:latest + pid_one_command: /usr/lib/systemd/systemd + intermediate_instructions: + - RUN dnf -y install yum which systemd-sysv initscripts + +- name: ubuntu-12.04 + driver: + image: ubuntu-upstart:12.04 + pid_one_command: /sbin/init + intermediate_instructions: + - RUN /usr/bin/apt-get update + - name: ubuntu-14.04 driver: image: ubuntu-upstart:14.04 - platform: ubuntu - disable_upstart: false - run_command: /sbin/init - provision_command: - - /usr/bin/apt-get update - - /usr/bin/apt-get install apt-transport-https net-tools -y + pid_one_command: /sbin/init + intermediate_instructions: + - RUN /usr/bin/apt-get update + +- name: ubuntu-16.04 + driver: + image: ubuntu:16.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + +- name: opensuse-13.2 + driver: + image: opensuse:13.2 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN zypper --non-interactive install aaa_base perl-Getopt-Long-Descriptive which net-tools + +- name: opensuse-42.1 + driver: + image: opensuse:42.1 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN zypper --non-interactive install aaa_base perl-Getopt-Long-Descriptive which hostname suites: - name: default diff --git a/.kitchen.yml b/.kitchen.yml index 1a6c9d1..728d370 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -7,13 +7,15 @@ driver: provisioner: name: chef_zero +verifier: + name: inspec + platforms: - name: centos-6.8 - name: centos-7.2 - name: ubuntu-12.04 - run_list: apt::default - name: ubuntu-14.04 - run_list: apt::default + - name: ubuntu-16.04 suites: - name: default diff --git a/.travis.yml b/.travis.yml index bf311ee..6047e57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,21 @@ sudo: required dist: trusty -# install the pre-release chef-dk. Use chef-stable-precise to install the stable release +# install the pre-release chef-dk. Use chef-stable-trusty to install the stable release addons: apt: sources: - - chef-stable-precise + - chef-current-trusty packages: - chefdk +# Don't `bundle install` which takes about 1.5 mins +install: echo "skip bundle install" + +branches: + only: + - master + services: docker env: @@ -18,20 +25,19 @@ env: - INSTANCE=add-ons-no-fqdn-ubuntu-1404 - INSTANCE=add-ons-no-fqdn-centos-7 -# Don't `bundle install` -install: echo "skip bundle install" - -# Ensure we make ChefDK's Ruby the default before_script: - # https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142230889 - 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 gem install kitchen-docker -script: - - /opt/chefdk/embedded/bin/chef --version - - /opt/chefdk/embedded/bin/cookstyle --version - - /opt/chefdk/embedded/bin/cookstyle - - /opt/chefdk/embedded/bin/foodcritic --version - - /opt/chefdk/embedded/bin/foodcritic . --exclude spec -f any -P - - /opt/chefdk/embedded/bin/rspec - - KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE} + +script: KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE} + +matrix: + include: + - before_script: + - 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 + - script: + - /opt/chefdk/bin/chef exec rake + env: UNIT_AND_LINT=1 diff --git a/Berksfile b/Berksfile index 82d8dd9..c91084f 100644 --- a/Berksfile +++ b/Berksfile @@ -3,6 +3,5 @@ source 'https://supermarket.chef.io' metadata group :integration do - cookbook 'apt' cookbook 'test', path: './test/fixtures/cookbooks/test' end diff --git a/test/fixtures/cookbooks/test/recipes/default.rb b/test/fixtures/cookbooks/test/recipes/default.rb index cd4157d..4c96c5e 100644 --- a/test/fixtures/cookbooks/test/recipes/default.rb +++ b/test/fixtures/cookbooks/test/recipes/default.rb @@ -1,11 +1 @@ -# This test recipe is used within test kitchen to perform additional -# setup, or to configure custom resources in the main cookbook. - -# workaround for https://github.com/chef/bento/issues/325 -remote_file '/etc/pki/tls/certs/ca-bundle.crt' do - source 'http://opscode-omnibus-cache.s3.amazonaws.com/cacerts-2014.07.15-fd48275847fa10a8007008379ee902f1' - checksum 'a9cce49cec92304d29d05794c9b576899d8a285659b3f987dd7ed784ab3e0621' - sensitive true - only_if { platform_family?('rhel') } - only_if { node['platform_version'].to_i == 5 } -end +apt_update 'update' if platform_family?('debian') diff --git a/test/integration/add-ons-no-fqdn/serverspec/default_spec.rb b/test/integration/add-ons-no-fqdn/default_spec.rb similarity index 85% rename from test/integration/add-ons-no-fqdn/serverspec/default_spec.rb rename to test/integration/add-ons-no-fqdn/default_spec.rb index ef6f3a7..fef5645 100644 --- a/test/integration/add-ons-no-fqdn/serverspec/default_spec.rb +++ b/test/integration/add-ons-no-fqdn/default_spec.rb @@ -1,6 +1,4 @@ -require_relative './spec_helper' - -describe 'chef-server' do +control 'chef-server' do describe package('chef-server-core') do it { should be_installed } end diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/default_spec.rb similarity index 93% rename from test/integration/default/serverspec/default_spec.rb rename to test/integration/default/default_spec.rb index 3a977a4..f4918a4 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/default_spec.rb @@ -1,7 +1,6 @@ -require_relative './spec_helper' require 'resolv' -describe 'chef-server' do +control 'chef-server' do describe package('chef-server-core') do it { should be_installed } end diff --git a/test/integration/helpers/serverspec/spec_helper.rb b/test/integration/helpers/serverspec/spec_helper.rb deleted file mode 100644 index 37af1b4..0000000 --- a/test/integration/helpers/serverspec/spec_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'serverspec' - -set :backend, :exec diff --git a/test/integration/no-fqdn/serverspec/default_spec.rb b/test/integration/no-fqdn/default_spec.rb similarity index 76% rename from test/integration/no-fqdn/serverspec/default_spec.rb rename to test/integration/no-fqdn/default_spec.rb index 2ac50d1..33ca4cb 100644 --- a/test/integration/no-fqdn/serverspec/default_spec.rb +++ b/test/integration/no-fqdn/default_spec.rb @@ -1,7 +1,6 @@ -require_relative './spec_helper' require 'resolv' -describe 'chef-server-no-fqdn' do +control 'chef-server-no-fqdn' do describe file('/etc/opscode/chef-server.rb') do its(:content) { should_not match(/^api_fqdn.*$/) } end