Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that virtualbox is able to start machines correctly #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -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]
157 changes: 157 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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'
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion Berksfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
site :opscode
source 'https://supermarket.chef.io'

metadata
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'rspec'
gem 'chefspec'
gem 'berkshelf'
29 changes: 18 additions & 11 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
13 changes: 10 additions & 3 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']}"
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

RSpec.configure do |config|
config.formatter = :documentation
config.color_enabled = true
config.color = true
end

at_exit { ChefSpec::Coverage.report! }
6 changes: 0 additions & 6 deletions test/integration/default/bats/installed.bats

This file was deleted.

8 changes: 8 additions & 0 deletions test/integration/default/virtualbox_spec.rb
Original file line number Diff line number Diff line change
@@ -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