Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

Commit

Permalink
refactoring to support more platform.
Browse files Browse the repository at this point in the history
* adding Debian support
  • Loading branch information
sunggun-yu committed Nov 15, 2015
1 parent a45939d commit a88a51f
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 34 deletions.
3 changes: 1 addition & 2 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ provisioner:

platforms:
- name: ubuntu-12.04
- name: debian-7.8
- name: centos-6.6
- name: centos-5.11
- name: oel-6.6
driver:
box: rafacas/oel66-plain
Expand Down Expand Up @@ -219,5 +219,4 @@ suites:
excludes:
- ubuntu-12.04
- centos-6.6
- centos-5.11
- oel-6.6
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'berkshelf', '~> 3.2.4'
gem 'berkshelf', '~> 4.0.1'
gem 'test-kitchen', '~> 1.4.0'
gem 'foodcritic', '4.0.0'

Expand Down
43 changes: 43 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,38 @@
# MongoDB version to install
default['mongodb3']['version'] = '3.0.4'

# Setup default package version attribute to install
pkg_version = node['mongodb3']['version']
case node['platform_family']
when 'rhel', 'fedora'
pkg_version = "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019
if node['platform'] == 'amazon'
pkg_version = "#{node['mongodb3']['version']}-1.amzn1" # ~FC019
end
end

# Setup default package repo url attribute for each platform family or platform
case node['platform']
when 'redhat', 'oracle','centos', 'fedora'
pkg_repo = "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/#{node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i686'}"
when 'amazon'
pkg_repo = 'https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.0/x86_64/'
when 'ubuntu'
pkg_repo = 'http://repo.mongodb.org/apt/ubuntu'
when 'debian'
pkg_repo = 'http://repo.mongodb.org/apt/debian'
end

# Setup apt variables
case node['platform']
when 'ubuntu'
apt_repo_keyserver = 'hkp://keyserver.ubuntu.com:80'
apt_repo_component = ['multiverse']
when 'debian'
apt_repo_keyserver = 'keyserver.ubuntu.com'
apt_repo_component = ['main']
end

# Default attribute for MongoDB installation
case node['platform_family']
when 'rhel', 'fedora'
Expand All @@ -36,6 +68,17 @@
config_processManagement_fork = nil
end

# MongoDB package repo url
default['mongodb3']['package']['repo']['url'] = pkg_repo

# MongoDB apt keyserver and key
default['mongodb3']['package']['repo']['apt']['keyserver'] = apt_repo_keyserver
default['mongodb3']['package']['repo']['apt']['key'] = '7F0CEB10'
default['mongodb3']['package']['repo']['apt']['components'] = apt_repo_component

# MongoDB package version to install
default['mongodb3']['package']['version'] = pkg_version

# MongoDB user:group
default['mongodb3']['user'] = mongo_user
default['mongodb3']['group'] = mongo_group
Expand Down
13 changes: 1 addition & 12 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,9 @@
# Install MongoDB package
install_package = %w(mongodb-org-server mongodb-org-shell mongodb-org-tools)

# Setup package version to install
package_version = node['mongodb3']['version']
case node['platform_family']
when 'rhel', 'fedora'
if node['platform'] == 'amazon'
package_version = "#{node['mongodb3']['version']}-1.amzn1" # ~FC019
else
package_version = "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019
end
end

install_package.each do |pkg|
package pkg do
version package_version
version node['mongodb3']['package']['version']
action :install
end
end
Expand Down
10 changes: 1 addition & 9 deletions recipes/mongos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,9 @@
# Install Mongos package
install_package = %w(mongodb-org-shell mongodb-org-mongos mongodb-org-tools)

# Setup package version to install
case node['platform_family']
when 'rhel', 'fedora'
package_version = "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019
when 'debian'
package_version = node['mongodb3']['version']
end

install_package.each do |pkg|
package pkg do
version package_version
version node['mongodb3']['package']['version']
action :install
end
end
Expand Down
16 changes: 6 additions & 10 deletions recipes/package_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
puts node['platform']

# Add the MongoDB 3.0 Package repository
case node['platform_family']
when 'rhel', 'fedora'
yum_base_url = "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/#{node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i686'}"
if node['platform'] == 'amazon'
yum_base_url = 'https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.0/x86_64/'
end
yum_repository 'mongodb-org-3.0' do
description 'MongoDB Repository'
baseurl yum_base_url
baseurl node['mongodb3']['package']['repo']['url']
action :create
gpgcheck false
enabled true
sslverify false
end
when 'debian'
apt_repository 'mongodb' do
uri 'http://repo.mongodb.org/apt/ubuntu'
uri node['mongodb3']['package']['repo']['url']
distribution "#{node['lsb']['codename']}/mongodb-org/stable"
components ['multiverse']
keyserver 'hkp://keyserver.ubuntu.com:80'
key '7F0CEB10'
components node['mongodb3']['package']['repo']['apt']['components']
keyserver node['mongodb3']['package']['repo']['apt']['keyserver']
key node['mongodb3']['package']['repo']['apt']['key']
action :add
end
include_recipe 'apt'
Expand Down

0 comments on commit a88a51f

Please sign in to comment.