diff --git a/.kitchen.yml b/.kitchen.yml index 3fe06ed..ac4e72c 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,23 +1,21 @@ --- -driver_plugin: vagrant +driver: + name: vagrant + +provisioner: + name: chef_zero + +verifier: + name: inspec platforms: -- name: debian-6 - driver_config: - box: opscode-debian-6.0.7 - box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_debian-6.0.7_chef-11.2.0.box - require_chef_omnibus: 11.4.0 -- name: ubuntu-12.04 - driver_config: - box: canonical-ubuntu-12.04 - box_url: http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box - require_chef_omnibus: true -- name: centos-6.3 - driver_config: - box: opscode-centos-6.3 - box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.3_chef-11.2.0.box + - name: debian-7.10 + - name: debian-8.4 + - name: ubuntu-14.04 + - name: centos-6.7 + - name: centos-7.2 suites: -- name: default - run_list: ["recipe[virtualbox]"] - attributes: {} + - name: default + run_list: + - recipe[virtualbox] diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..0f4fdba --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,157 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2016-06-28 16:23:23 -0400 using RuboCop version 0.41.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +Lint/AmbiguousRegexpLiteral: + Exclude: + - 'test/integration/default/virtualbox_spec.rb' + +# Offense count: 1 +Lint/ParenthesesAsGroupedExpression: + Exclude: + - 'recipes/webservice.rb' + +# Offense count: 14 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes. +# URISchemes: http, https +Metrics/LineLength: + Max: 154 + +# Offense count: 1 +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'libraries/helpers.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, no_empty_lines +Style/EmptyLinesAroundBlockBody: + Exclude: + - 'spec/default_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, no_empty_lines +Style/EmptyLinesAroundModuleBody: + Exclude: + - 'libraries/helpers.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Style/FirstParameterIndentation: + Exclude: + - 'recipes/systemservice.rb' + - 'recipes/webportal.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets +Style/HashSyntax: + Exclude: + - 'recipes/systemservice.rb' + - 'recipes/webportal.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Style/IndentHash: + Exclude: + - 'attributes/webportal.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/MultilineIfThen: + Exclude: + - 'recipes/webportal.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/NumericLiterals: + MinDigits: 9 + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'metadata.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'libraries/helpers.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/SpaceAfterComma: + Exclude: + - 'recipes/user.rb' + - 'recipes/webportal.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForEmptyBraces, SupportedStyles. +# SupportedStyles: space, no_space, compact +Style/SpaceInsideHashLiteralBraces: + EnforcedStyle: no_space + +# Offense count: 51 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'attributes/webportal.rb' + - 'libraries/helpers.rb' + - 'metadata.rb' + - 'recipes/default.rb' + - 'recipes/systemservice.rb' + - 'recipes/user.rb' + - 'recipes/webportal.rb' + - 'recipes/webservice.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: final_newline, final_blank_line +Style/TrailingBlankLines: + Exclude: + - 'attributes/user.rb' + - 'recipes/systemservice.rb' + - 'recipes/webportal.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. +# SupportedStyles: comma, consistent_comma, no_comma +Style/TrailingCommaInLiteral: + Exclude: + - 'attributes/default.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/TrailingWhitespace: + Exclude: + - 'spec/default_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/UnneededInterpolation: + Exclude: + - 'libraries/helpers.rb' + - 'recipes/webservice.rb' diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e3f07f0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +sudo: required +dist: trusty + +# install the stable release chefdk. +addons: + apt: + sources: + - chef-stable-precise + packages: + - chefdk + +install: echo "skip bundle install" + +# Ensure we make ChefDK's Ruby the default +before_script: + - eval "$(/opt/chefdk/bin/chef shell-init bash)" + +script: + - /opt/chefdk/embedded/bin/chef --version + - /opt/chefdk/embedded/bin/rubocop --version + - /opt/chefdk/embedded/bin/rubocop --config .rubocop_todo.yml + - /opt/chefdk/embedded/bin/bundle install + - /opt/chefdk/embedded/bin/bundle exec rspec spec diff --git a/Berksfile b/Berksfile index 97d7d42..34fea21 100644 --- a/Berksfile +++ b/Berksfile @@ -1,2 +1,3 @@ -site :opscode +source 'https://supermarket.chef.io' + metadata diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..9acea36 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'rspec' +gem 'chefspec' +gem 'berkshelf' diff --git a/attributes/default.rb b/attributes/default.rb index a7eb105..9a3a08e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -17,16 +17,23 @@ # limitations under the License. # +default['virtualbox']['url'] = case node['platform_family'] + when 'mac_os_x' + 'http://download.virtualbox.org/virtualbox/4.2.12/VirtualBox-4.2.12-84980-OSX.dmg' + when 'windows' + 'http://download.virtualbox.org/virtualbox/4.2.12/VirtualBox-4.2.12-84980-Win.exe' + end -default['virtualbox']['url'] = '' -default['virtualbox']['version'] = '' +default['virtualbox']['version'] = case node['platform_family'] + when 'windows' + Vbox::Helpers.vbox_version(node['virtualbox']['url']) + when 'debian', 'rhel', 'fedora' + '4.3' + end -case node['platform_family'] -when 'mac_os_x' - default['virtualbox']['url'] = 'http://download.virtualbox.org/virtualbox/4.2.12/VirtualBox-4.2.12-84980-OSX.dmg' -when 'windows' - default['virtualbox']['url'] = 'http://download.virtualbox.org/virtualbox/4.2.12/VirtualBox-4.2.12-84980-Win.exe' - default['virtualbox']['version'] = Vbox::Helpers.vbox_version(node['virtualbox']['url']) -when 'debian', 'rhel', 'fedora' - default['virtualbox']['version'] = '4.3' -end +default['virtualbox']['package_gpgkey_url'] = value_for_platform( + debian: { + '>= 8' => 'http://download.virtualbox.org/virtualbox/debian/oracle_vbox_2016.asc', + }, + default: 'http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc' +) diff --git a/recipes/default.rb b/recipes/default.rb index b51fa07..37ec8b0 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -46,21 +46,28 @@ apt_repository 'oracle-virtualbox' do uri 'http://download.virtualbox.org/virtualbox/debian' - key 'http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc' + key node['virtualbox']['package_gpgkey_url'] distribution node['lsb']['codename'] components ['contrib'] end + package "linux-headers-#{node['kernel']['release']}" package "virtualbox-#{node['virtualbox']['version']}" package 'dkms' when 'rhel', 'fedora' yum_repository 'oracle-virtualbox' do - description "#{node['platform_family']} $releasever - $basearch - Virtualbox" + description "#{node['platform_family']} $releasever - $basearch - Virtualbox" baseurl "http://download.virtualbox.org/virtualbox/rpm/#{node['platform_family']}/$releasever/$basearch" gpgcheck true - gpgkey 'http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc' + gpgkey node['virtualbox']['package_gpgkey_url'] + end + + package 'gcc' + + package 'kernel-devel' do + version node['kernel']['release'].sub(".#{node['kernel']['machine']}", '') end package "VirtualBox-#{node['virtualbox']['version']}" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a8786cc..7fe8b16 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,7 @@ RSpec.configure do |config| config.formatter = :documentation - config.color_enabled = true + config.color = true end at_exit { ChefSpec::Coverage.report! } diff --git a/test/integration/default/bats/installed.bats b/test/integration/default/bats/installed.bats deleted file mode 100644 index cdd18a3..0000000 --- a/test/integration/default/bats/installed.bats +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bats - -@test 'virtualbox-4.3 is installed' { - run test "rpm -qa Virtualbox-4.3 || dpkg-query -s virtualbox-4.3" - [ "$status" -eq 0 ] -} diff --git a/test/integration/default/virtualbox_spec.rb b/test/integration/default/virtualbox_spec.rb new file mode 100644 index 0000000..f821410 --- /dev/null +++ b/test/integration/default/virtualbox_spec.rb @@ -0,0 +1,8 @@ +describe package('VirtualBox-4.3') do + it { should be_installed } +end + +describe command('vboxmanage --version') do + its('stdout') { should match /4.3/ } + its('stdout') { should_not match /WARNING: The vboxdrv kernel module is not loaded./ } +end