Skip to content

Commit

Permalink
Chef 12 migration (#22)
Browse files Browse the repository at this point in the history
* chef 12 migration

* update for chef 12

* fix verify_version

* fix deprecation warning

* fix tests for chef 12

* updating filesystem cookbook

* updating log spec for 100% coverage

* updating ruby-version

* updating rake and berks for chef12

* locking berksfile.lock

* locking berksfile.lock

* putting in apt-compile-time

* adding apt to runlist
  • Loading branch information
rshade authored Jan 10, 2017
1 parent f21dbf9 commit d4fb00e
Show file tree
Hide file tree
Showing 31 changed files with 486 additions and 270 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.vagrant
Berksfile.lock
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
/cookbooks
cache_dir

# Bundler
Gemfile.lock
Expand All @@ -16,3 +16,10 @@ bin/*
VERSION
.kitchen/
.kitchen.local.yml

doc/
.yardoc/
berks-cookbooks/
knife.rb
syntaxcache/
coverage/
36 changes: 25 additions & 11 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: '11.18'
customize:
cpus: 1
memory: 512
ssh:
insert_key: false

provisioner:
name: chef_zero
always_update_cookbooks: true
require_chef_omnibus: 12.16.42
log_level: info
log_file: /var/log/chef-solo.log

platforms:
- name: centos-7.2
driver_config:
box: bento/centos-7.2
- name: centos-6.8
driver_config:
box: bento/centos-6.8
- name: ubuntu-12.04
driver_config:
box: opscode-ubuntu-12.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
box: bento/ubuntu-12.04
- name: ubuntu-14.04
driver_config:
box: opscode-ubuntu-14.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-14.04_provisionerless.box
- name: centos-6.8
driver_config:
box: opscode-centos-6.8
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.8_provisionerless.box
box: bento/ubuntu-14.04

suites:
- name: default
run_list: ["recipe[rs-storage]"]
attributes: {}
run_list: ['recipe[apt]','recipe[rs-storage]']
attributes:
apt:
compile_time_update: true
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--format documentation
30 changes: 30 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
AllCops:
Exclude:
- 'berks-cookbooks/**/*'
- 'knife.rb'
Style/AccessorMethodName:
Exclude:
- 'Rakefile'
- 'libraries/helper.rb'
Lint/UselessAssignment:
Exclude:
- 'recipes/stripe.rb'
- 'recipes/volume.rb'
Style/PredicateName:
Exclude:
- 'libraries/helper.rb'
Lint/EndAlignment:
Exclude:
- 'recipes/default.rb'
Metrics/BlockNesting:
Exclude:
- 'recipes/default.rb'
Style/DoubleNegation:
Exclude:
- 'libraries/helper.rb'
Style/RegexpLiteral:
Exclude:
- 'libraries/helper.rb'
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'recipes/stripe.rb'
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3.1
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
language: ruby
rvm:
- 2.0.0
- 1.9.3
before_script: bundle exec berks install
script: bundle exec strainer test --except kitchen
- 2.3.1
before_install:
- curl -L https://www.getchef.com/chef/install.sh | sudo bash -s -- -P chefdk -v 1.0.3
- gem install bundler -v 1.11.2
install:
- chef exec bundle install --jobs=3 --retry=3
before_script: chef exec rake setup_test_environment
script: "./.travis_install.sh"
notifications:
slack:
secure: jypk2i83t2b5e1oAGGV3mcIWGesJYNk1MnH/kDsgClD16pLKfOE8rnyduhwNdNL1NlVURbFMjp9ZEGJQeYqnLs9ZXnr3ez7lDmFoM9YWVE030664tyTmaXYcksQBINfYwMrO13oih8bvXwStLshItxAbNHpKiu4/qmzDVl+rOtE=
secure: FBCQb9ApoEzqZisD4IbFmw+ZujFU6kwRkCiwES6qmJB22cgMsFqBB/+KOv3OLAFTNVjQfsTGEyzeqXFW9Chhze+xOGSxBMKOtZI/+5OVTvNithBhwOBlcb3IW546mlfGMXorWlY6JEb9NO0c1oJ7Oe9wB9WIELaQy6MaF9PS7q0=
8 changes: 8 additions & 0 deletions .travis_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set -ev
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
git clone https://github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_REPO_SLUG
cd $TRAVIS_REPO_SLUG
git checkout master
git checkout -qf $TRAVIS_COMMIT
fi
chef exec rake except_kitchen
9 changes: 5 additions & 4 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
site :opscode
source 'https://supermarket.chef.io'

cookbook "rightscale_volume", github: 'rightscale-cookbooks/rightscale_volume'
cookbook "rightscale_backup", github: 'rightscale-cookbooks/rightscale_backup'
cookbook 'windows', '1.40.0'# keep for compatiblity with chef 11, can remove with chef 12
metadata

cookbook 'filesystem', github: 'rightscale-cookbooks-contrib/filesystem_cookbook', branch: 'update_lvm_cookbook_dependency_3'
cookbook 'rightscale_volume', github: 'rightscale-cookbooks/rightscale_volume'
cookbook 'rightscale_backup', github: 'rightscale-cookbooks/rightscale_backup'
53 changes: 53 additions & 0 deletions Berksfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
DEPENDENCIES
filesystem
git: https://github.com/rightscale-cookbooks-contrib/filesystem_cookbook.git
revision: 9c2a21a8aa41b16d3774ed5292f9a31b018dee92
branch: update_lvm_cookbook_dependency_3
rightscale_backup
git: https://github.com/rightscale-cookbooks/rightscale_backup.git
revision: 454fa9f582943f0ace47dd90bf6106e7bf752a93
rightscale_volume
git: https://github.com/rightscale-cookbooks/rightscale_volume.git
revision: 48c24ba0f0815e86200793ef50fe27dce9f09d8e
rs-storage
path: .
metadata: true

GRAPH
apt (5.0.1)
compat_resource (>= 12.16.3)
build-essential (7.0.3)
compat_resource (>= 12.16.3)
mingw (>= 1.1)
seven_zip (>= 0.0.0)
chef_handler (2.1.0)
compat_resource (12.16.3)
filesystem (0.11.0)
lvm (~> 3.1)
xfs (>= 0.0.0)
lvm (3.1.0)
marker (1.0.1)
mingw (1.2.4)
compat_resource (>= 0.0.0)
seven_zip (>= 0.0.0)
ohai (4.2.3)
compat_resource (>= 12.14.7)
rightscale_backup (2.0.0)
build-essential (>= 0.0.0)
rightscale_volume (~> 2.0.0)
rightscale_volume (2.0.0)
build-essential (>= 0.0.0)
rs-storage (2.0.0)
apt (>= 0.0.0)
build-essential (>= 0.0.0)
chef_handler (>= 0.0.0)
filesystem (>= 0.0.0)
lvm (~> 3.1)
marker (>= 0.0.0)
rightscale_backup (~> 2.0.0)
rightscale_volume (~> 2.0.0)
seven_zip (2.0.2)
windows (>= 1.2.2)
windows (2.1.1)
ohai (>= 4.0.0)
xfs (2.0.1)
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ rs-storage Cookbook CHANGELOG

This file is used to list changes made in each version of the rs-storage cookbook.

v1.2.1
v2.0.0
------

- Add support for Chef 12
- Remove support for Chef 11

v1.2.1
------
- pin Gems and cookbooks using Gemfile.lock and Berksfile.lock


Expand Down
14 changes: 2 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
source 'https://rubygems.org'

gem 'berkshelf'
gem 'thor-foodcritic'
gem 'rake'
gem 'chef', '~> 12.16'

group :integration do
gem 'test-kitchen', '~> 1.2.1'
gem 'kitchen-vagrant', '0.15.0'
gem 'strainer', '~> 3.3.0'
gem 'chefspec', '~> 3.4.0'
gem 'travis-lint'
gem 'rspec-expectations', '~> 2.14.0'
gem 'buff-ignore','1.1.1'
gem 'rack', '1.6.4'
gem 'json','~> 1.8.0'
gem 'net-http-persistent', '= 2.9.4'
end
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Github Repository: [https://github.com/rightscale-cookbooks/rs-storage](https://

# Requirements

* Requires Chef 11
* Requires Ruby 1.9 or higher
* Requires Chef 12
* Requires Ruby 2.3.1
* Requires [RightLink 10](http://docs.rightscale.com/rl10/) See cookbook version 1.0.7 for RightLink 6 support
* Platform
* Ubuntu 12.04
* CentOS 6
* Ubuntu 12.04, 14.04
* CentOS 6, 7
* Cookbooks
* [chef_handler](http://community.opscode.com/cookbooks/chef_handler)
* [filesystem](http://community.opscode.com/cookbooks/filesystem)
Expand Down
113 changes: 113 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
require 'rspec/core/rake_task'
require 'foodcritic'
require 'kitchen'

directory = File.expand_path(File.dirname(__FILE__))

desc 'Sets up knife, and vendors cookbooks'
task :setup_test_environment do
File.open('knife.rb', 'w+') do |file|
file.write <<-EOF
log_level :debug
log_location STDOUT
cookbook_path ['.', 'berks-cookbooks/' ]
EOF
end
sh('berks vendor')
end

desc 'verifies version and changelog'
task :verify_version do
def old_version?
f = `git show master:metadata.rb`
f.each_line do |line|
if line =~ /^version/
_k, v = line.strip.split
@old_version = v
end
end
@old_version
end

def new_version?
f = File.read('metadata.rb')
f.each_line do |line|
if line =~ /^version/
_k, v = line.strip.split
@new_version = v
end
end
@new_version
end

if `git rev-parse --abbrev-ref HEAD`.strip != ('master' && 'HEAD')
old_version = old_version?.tr('\'', '')
new_version = new_version?.tr('\'', '')
puts "Verifying Metdata Version - Old:#{old_version}, New:#{new_version}"
if old_version == new_version
raise 'You need to increment version before test will pass'
end

puts "Verifying Changelog Contains Version #{new_version}"
counter = 0
f = File.read('CHANGELOG.md')
f.each_line do |line|
counter += 1 if line.match new_version
end
raise 'CHANGELOG update needed' if counter == 0
end
end

desc 'runs cookstyle'
task cookstyle: [:setup_test_environment] do
cmd = 'chef exec cookstyle -D --format offenses --display-cop-names'
puts cmd
sh(cmd)
end

desc 'runs foodcritic'
task :foodcritic do
cmd = "chef exec foodcritic --epic-fail any #{directory}"
puts cmd
sh(cmd)
end

desc 'runs foodcritic linttask'
task :fc_new do
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
fail_tags: ['any']
}
end
end

desc 'runs rspec'
task :rspec do
cmd = 'chef exec rspec --color --format documentation'
puts cmd
sh(cmd)
end

desc 'runs testkitchen'
task :kitchen do
cmd = 'chef exec kitchen test --concurrency=2'
puts cmd
sh(cmd)
end

desc 'clean up test files'
task :clean do
cmd = 'rm -fr berks-cookbooks knife.rb'
puts cmd
sh(cmd)
end

desc 'runs all tests except kitchen'
task except_kitchen: [:verify_version, :cookstyle, :foodcritic, :rspec] do
puts 'running all tests except kitchen'
end

desc 'runs all tests'
task all: [:except_kitchen, :kitchen] do
puts 'running all tests'
end
4 changes: 0 additions & 4 deletions Strainerfile

This file was deleted.

14 changes: 0 additions & 14 deletions Thorfile

This file was deleted.

Loading

0 comments on commit d4fb00e

Please sign in to comment.