Commit 4227febe authored by Sean OMeara's avatar Sean OMeara
Browse files

Porting to use cookbook yum ~> 3.0, cleaning up style, fixing up tests

parent d45afd95
.vagrant
Berksfile.lock
Gemfile.lock
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
.bundle
.cache
.kitchen
bin
Gemfile.lock
.kitchen/
.kitchen.local.yml
---
driver_plugin: vagrant
driver_plugin: digitalocean
driver_config:
require_chef_omnibus: true
digitalocean_client_id: <%= ENV['DIGITAL_OCEAN_CLIENT_ID'] %>
digitalocean_api_key: <%= ENV['DIGITAL_OCEAN_API_KEY'] %>
aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
aws_ssh_key_id: <%= ENV['AWS_KEYPAIR_NAME'] %>
ssh_key: <%= ENV['AWS_PRIVATE_KEY_PATH'] %>
rackspace_username: <%= ENV['RACKSPACE_USERNAME'] %>
rackspace_api_key: <%= ENV['RACKSPACE_API_KEY'] %>
require_chef_omnibus: latest
platforms:
- name: ubuntu-12.04
- name: centos-5.8
driver_plugin: digitalocean
driver_config:
box: opscode-ubuntu-12.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
run_list: ["recipe[apt]"]
- name: ubuntu-10.04
driver_config:
box: opscode-ubuntu-10.04
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box
run_list: ["recipe[apt]"]
image_id: 1601
flavor_id: 63
region_id: 1
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
- name: centos-6.4
driver_plugin: digitalocean
driver_config:
box: opscode-centos-6.4
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
image_id: 562354
flavor_id: 63
region_id: 1
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
- name: centos-5.9
- name: amazon-2013.09
driver_plugin: ec2
driver_config:
box: opscode-centos-5.9
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box
image_id: ami-3be4bc52
username: ec2-user
# - name: ubuntu-10.04
# driver_plugin: digitalocean
# driver_config:
# image_id: 14097
# flavor_id: 63
# region_id: 1
# ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
# run_list:
# - recipe[apt::default]
# - name: ubuntu-12.04
# driver_plugin: digitalocean
# driver_config:
# image_id: 284203
# flavor_id: 63
# region_id: 1
# ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
# run_list:
# - recipe[apt::default]
suites:
- name: default
run_list:
- "recipe[minitest-handler]"
- "recipe[erlang]"
- 'recipe[erlang]'
attributes: {}
- name: gui_tools
run_list:
- "recipe[minitest-handler]"
- "recipe[erlang]"
attributes: {erlang: {gui_tools: true}}
excludes: ["centos-5.9", "centos-6.4"]
- 'recipe[erlang]'
attributes: { erlang: { gui_tools: true } }
excludes: ['centos-5.8', 'centos-6.4', 'amazon-2013.09']
- name: esl
run_list:
- "recipe[minitest-handler]"
- "recipe[erlang::esl]"
- 'recipe[erlang::esl]'
attributes: {}
excludes: ["centos-5.9", "centos-6.4"]
excludes: ['centos-5.8']
- name: source
run_list:
- "recipe[minitest-handler]"
- "recipe[erlang::source]"
- 'recipe[erlang::source]'
attributes: {}
Encoding:
Enabled: false
LineLength:
Max: 200
HashSyntax:
EnforcedStyle: hash_rockets
language: ruby
bundler_args: --without development integration
rvm:
- 1.9.3
- 2.0.0
before_install:
- "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
before_script:
- bundle exec berks install
script:
# - bundle exec foodcritic -f any . --tags ~FC005
- bundle exec rubocop
# - bundle exec rspec --color --format progress
......@@ -3,6 +3,9 @@ site :opscode
metadata
group :integration do
cookbook "apt"
cookbook "minitest-handler"
cookbook 'apt'
cookbook 'minitest-handler'
cookbook 'yum', '~> 3.0'
cookbook 'yum-epel'
cookbook 'yum-repoforge'
end
source 'https://rubygems.org'
gem 'berkshelf', '~> 2.0'
gem 'chefspec', '~> 3.0'
gem 'foodcritic', '~> 3.0'
gem 'rubocop'
group :integration do
gem 'test-kitchen', '~> 1.0'
gem 'kitchen-vagrant', '~> 0.11'
gem 'kitchen-digitalocean'
gem 'kitchen-ec2'
end
......@@ -16,11 +16,11 @@
#
default['erlang']['gui_tools'] = false
default['erlang']['install_method'] = "package"
default['erlang']['install_method'] = 'package'
default['erlang']['source']['version'] = "R15B01"
default['erlang']['source']['version'] = 'R15B01'
default['erlang']['source']['url'] = "http://erlang.org/download/otp_src_#{node['erlang']['source']['version']}.tar.gz"
default['erlang']['source']['checksum'] = "f94f7de7328af3c0cdc42089c1a4ecd03bf98ec680f47eb5e6cddc50261cabde"
default['erlang']['source']['checksum'] = 'f94f7de7328af3c0cdc42089c1a4ecd03bf98ec680f47eb5e6cddc50261cabde'
default['erlang']['esl']['version'] = nil
default['erlang']['esl']['lsb_codename'] = node['lsb']['codename']
#
# Cookbook:: erlang
# Minitest Chef Handler
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2012, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require File.expand_path('../support/helpers', __FILE__)
describe 'erlang::default' do
include Helpers::Erlang
it 'doesnt install the gui_tools if the attribute is false (default)' do
skip unless node['platform_family'] == 'debian'
skip if node['erlang']['gui_tools']
package("erlang-gs").wont_be_installed
end
it 'can process erlang code with the erl command ' do
erl = shell_out("erl -myflag 1 <<-EOH
init:get_argument(myflag).
EOH
")
assert_includes(erl.stdout,'{ok,[["1"]]}')
end
end
#
# Cookbook:: erlang_test
# Minitest Chef Handler
#
# Copyright:: Copyright (c) 2013, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require File.expand_path('../support/helpers', __FILE__)
describe_recipe 'erlang::erlang_solutions' do
include Helpers::Erlang
it 'installs the esl-erlang package' do
package("esl-erlang").must_be_installed
end
it "can successfully run 'erl'" do
erl = shell_out("erl -myflag 1 <<-EOH
init:get_argument(myflag).
EOH
")
assert_includes(erl.stdout,'{ok,[["1"]]}')
end
end
#
# Cookbook:: erlang
# Minitest Chef Handler
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2012, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require File.expand_path('../support/helpers', __FILE__)
describe 'erlang::default' do
include Helpers::Erlang
it 'installs the x11 package if gui_tools is true' do
skip unless node['platform_family'] == 'debian'
package("erlang-gs").must_be_installed
end
end
#
# Cookbook:: erlang
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2012, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
module Helpers
module Erlang
require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
include MiniTest::Chef::Assertions
include MiniTest::Chef::Context
include MiniTest::Chef::Resources
end
end
name "erlang"
maintainer "Opscode, Inc."
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs erlang, optionally install GUI tools."
version "1.3.7"
name 'erlang'
maintainer 'Opscode, Inc.'
maintainer_email 'cookbooks@opscode.com'
license 'Apache 2.0'
description 'Installs erlang, optionally install GUI tools.'
version '1.3.7'
depends "apt", ">= 1.7.0"
depends "yum", '< 3.0'
depends "build-essential"
depends 'apt', '>= 1.7.0'
depends 'yum', '~> 3.0'
depends 'yum-epel'
depends 'yum-erlang_solutions'
depends 'build-essential'
recipe "erlang", "Installs Erlang via native package, source, or Erlang Solutions package"
recipe "erlang::package", "Installs Erlang via native package"
recipe "erlang::source", "Installs Erlang via source"
recipe "erlang::esl", "Installs Erlang from Erlang Solutions' package repositories"
recipe 'erlang', 'Installs Erlang via native package, source, or Erlang Solutions package'
recipe 'erlang::package', 'Installs Erlang via native package'
recipe 'erlang::source', 'Installs Erlang via source'
recipe 'erlang::esl', "Installs Erlang from Erlang Solutions' package repositories"
%w{ ubuntu debian redhat centos fedora scientific amazon oracle }.each do |os|
%w{ ubuntu debian redhat centos scientific amazon oracle }.each do |os|
supports os
end
......@@ -33,57 +33,31 @@ when 'debian'
action :add
end
when 'rhel'
case node['platform']
when 'centos', 'fedora'
if platform?('centos') && node['platform_version'].to_i == 5
Chef::Log.fatal("Erlang Solutions pacakge repositories are not available for Centos 5")
raise
else
include_recipe 'yum'
if platform?('centos')
include_recipe "yum::repoforge"
end
yum_key "RPM-KEY-Erlang-Solutions" do
# Yes, yes, I know the URL has 'debian' in it... that's the address
url "http://binaries.erlang-solutions.com/debian/erlang_solutions.asc"
action :add
end
package 'esl-erlang' do
version node['erlang']['esl']['version'] if node['erlang']['esl']['version']
end
# This replicates the files found at
# http://binaries.erlang-solutions.com/rpm/fedora/erlang_solutions.repo
# http://binaries.erlang-solutions.com/rpm/centos/erlang_solutions.repo
yum_repository "erlang-solutions" do
description "#{node['platform']} $releasever - $basearch - Erlang Solutions"
url "http://binaries.erlang-solutions.com/rpm/#{node['platform']}/$releasever/$basearch"
key "RPM-KEY-Erlang-Solutions"
enabled 1
end
end
when 'rhel'
if node['platform_version'].to_i
Chef::Log.fatal('Erlang Solutions pacakge repositories are not available for EL5')
else
Chef::Log.fatal("Erlang Solutions pacakge repositories are currently not supported for RHEL family #{node['platform']} systems")
raise
# include_recipe 'yum-repoforge'
include_recipe 'yum-erlang_solutions'
end
package 'erlang' do
version node['erlang']['esl']['version'] if node['erlang']['esl']['version']
end
else
Chef::Log.fatal("Erlang Solutions pacakge repositories are currently not supported for #{node['platform_family']} systems")
raise
end
package "esl-erlang" do
version node['erlang']['esl']['version'] if node['erlang']['esl']['version']
end
# There's a small bug in the package for Ubuntu 10.04... this fixes
# it. Solution found at
# https://github.com/davidcoallier/bigcouch/blob/f6a6daf7590ecbab4d9dc4747624573b3137dfad/README.md#ubuntu-1004-lts-potential-issues
if platform?("ubuntu") && node['platform_version'] == "10.04"
bash "ubuntu-10.04-LTS-erlang-fix" do
user "root"
cwd "/usr/lib/erlang/man/man5"
if platform?('ubuntu') && node['platform_version'] == '10.04'
bash 'ubuntu-10.04-LTS-erlang-fix' do
user 'root'
cwd '/usr/lib/erlang/man/man5'
code <<-EOS
rm modprobe.d.5
ln -s modprobe.conf.5.gz modprobe.d.5
......
#
# Cookbook Name:: erlang
# Recipe:: default
# Author:: Joe Williams <joe@joetify.com>
......@@ -21,29 +22,26 @@
#
case node['platform_family']
when "debian"
erlpkg = node['erlang']['gui_tools'] ? "erlang-x11" : "erlang-nox"
when 'debian'
erlpkg = node['erlang']['gui_tools'] ? 'erlang-x11' : 'erlang-nox'
package erlpkg
package "erlang-dev"
when "rhel"
include_recipe "yum::epel"
yum_repository "erlang" do
name "EPELErlangrepo"
url "http://repos.fedorapeople.org/repos/peter/erlang/epel-5Server/$basearch"
description "Updated erlang yum repository for RedHat / Centos 5.x - #{node['kernel']['machine']}"
action :add
only_if { node['platform_version'].to_f >= 5.0 && node['platform_version'].to_f < 6.0 }
package 'erlang-dev'
when 'rhel'
case node['platform_version'].to_i
when 5
include_recipe 'yum-epel'
yum_repository 'EPELErlangrepo' do
description "Updated erlang yum repository for RedHat / Centos 5.x - #{node['kernel']['machine']}"
baseurl 'http://repos.fedorapeople.org/repos/peter/erlang/epel-5Server/$basearch'
gpgcheck false
action :create
end
else
include_recipe 'yum-erlang_solutions'
end
package "erlang"
else
package "erlang"
package 'erlang'
end
......@@ -20,15 +20,15 @@
# limitations under the License.
#
include_recipe "build-essential"
include_recipe 'build-essential'
erlang_deps = case node["platform_family"]
when "debian"
[ "libncurses5-dev", "openssl", "libssl-dev" ]
when "rhel", "fedora"
[ "ncurses-devel", "openssl-devel" ]
erlang_deps = case node['platform_family']
when 'debian'
%w{ libncurses5-dev openssl libssl-dev }
when 'rhel', 'fedora'
%w{ ncurses-devel openssl-devel }
else
[ ]
[]
end
erlang_deps.each do |pkg|
......@@ -37,7 +37,7 @@ erlang_deps.each do |pkg|
end
end
bash "install-erlang" do
bash 'install-erlang' do
cwd Chef::Config[:file_cache_path]
code <<-EOH
tar -xzf otp_src_#{node['erlang']['source']['version']}.tar.gz
......@@ -49,8 +49,8 @@ end
remote_file File.join(Chef::Config[:file_cache_path], "otp_src_#{node['erlang']['source']['version']}.tar.gz") do
source node['erlang']['source']['url']
owner "root"
owner 'root'
mode 0644
checksum node['erlang']['source']['checksum']
notifies :run, "bash[install-erlang]", :immediately
notifies :run, 'bash[install-erlang]', :immediately
end
require 'chefspec'
require 'chefspec/berkshelf'
@test "run an erl command" {
sudo bash -c 'erl -myflag 1 <<-EOH
init:get_argument(myflag).
EOH'
}
@test "run an erl command" {
sudo bash -c 'erl -myflag 1 <<-EOH
init:get_argument(myflag).
EOH'
}
@test "run an erl command" {
sudo bash -c 'erl -myflag 1 <<-EOH
init:get_argument(myflag).
EOH'
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment