Skip to content
This repository was archived by the owner on Mar 17, 2023. It is now read-only.
Merged
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
28 changes: 13 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
---
sudo: false
language: ruby
cache: bundler
bundler_args: --without system_tests
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
before_install: rm Gemfile.lock || true
script: bundle exec rake validate lint spec
matrix:
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.4.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.6.0"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.1.6
env: PUPPET_GEM_VERSION='~> 4.0' COVERAGE=yes STRICT_VARIABLES=yes
- rvm: 2.1.6
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#stable
- rvm: 2.1.5
env: PUPPET_GEM_VERSION='~> 3.0' FUTURE_PARSER=yes
- rvm: 2.1.5
env: PUPPET_GEM_VERSION='~> 3.0'
- rvm: 1.9.3
env: PUPPET_GEM_VERSION='~> 3.0'
notifications:
email: false
50 changes: 41 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
source 'https://rubygems.org'

puppetversion = ENV.key?('PUPPET_GEM_VERSION') ? "#{ENV['PUPPET_GEM_VERSION']}" : ['>= 3.3']
facterversion = ENV.key?('FACTER_GEM_VERSION') ? "#{ENV['FACTER_GEM_VERSION']}" : ['>= 1.7']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 0.3.2'
gem 'facter', facterversion
gem 'rspec', '< 3.2.0'
source ENV['GEM_SOURCE'] || "https://rubygems.org"

def location_for(place, version = nil)
if place =~ /^((?:git|https?)[:@][^#]*)#(.*)/
[version, { :git => $1, :branch => $2, :require => false }].compact
elsif place =~ /^file:\/\/(.*)/
['>= 0', { :path => File.expand_path($1), :require => false }]
else
[place, version, { :require => false }].compact
end
end

gem 'puppetlabs_spec_helper', '>= 0.1.0', :require => false
gem 'puppet-lint', '>= 0.3.2', :require => false
gem 'rspec-puppet', '>= 2.3.2', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'metadata-json-lint', :require => false
# rubi <1.9 versus rake 11.0.0 workaround
gem 'rake', '< 11.0.0', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
gem 'json', '< 2.0.0', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
gem 'json_pure', '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')

gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])

# Only explicitly specify Facter/Hiera if a version has been specified.
# Otherwise it can lead to strange bundler behavior. If you are seeing weird
# gem resolution behavior, try setting `DEBUG_RESOLVER` environment variable
# to `1` and then run bundle install.
gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION']
gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION']


# Evaluate Gemfile.local if it exists
if File.exists? "#{__FILE__}.local"
eval(File.read("#{__FILE__}.local"), binding)
end

# Evaluate ~/.gemfile if it exists
if File.exists?(File.join(Dir.home, '.gemfile'))
eval(File.read(File.join(Dir.home, '.gemfile')), binding)
end
7 changes: 3 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
PuppetLint.configuration.send('disable_variable_is_lowercase')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"]

desc "Validate manifests, templates, and ruby files in lib."
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
sh "puppet parser validate --noop #{Dir['manifests/**/*.pp'].join(" ")}"
Dir['lib/**/*.rb'].each do |lib_file|
sh "ruby -c #{lib_file}"
end
Expand Down
18 changes: 17 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,27 @@
before => Anchor['mongodb::install::end']
}

package { 'mongodb-package':

case $::osfamily {
'Debian': {
package { 'mongodb-package':
ensure => $package_ensure,
name => $::mongodb::repos::apt::package_name,
require => $mongodb_10gen_package_require,
before => [Anchor['mongodb::install::end']]
}
}
'RedHat': {
package { 'mongodb-package':
ensure => $package_ensure,
name => $::mongodb::package_name,
require => $mongodb_10gen_package_require,
before => [Anchor['mongodb::install::end']]
}
}
default: {
fail("Unsupported OS ${::osfamily}")
}
}

}
13 changes: 6 additions & 7 deletions manifests/repos/yum.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
#
class mongodb::repos::yum {

yumrepo { 'mongodb_yum_repo':
descr => '10gen MongoDB Repo',
baseurl => 'http://downloads-distro.mongodb.org/repo/redhat/os/$basearch',
enabled => 1,
gpgcheck => 0;
}

yumrepo { 'mongodb_yum_repo':
enabled => 1,
descr => '10gen MongoDB Repo',
baseurl => 'http://downloads-distro.mongodb.org/repo/redhat/os/$basearch',
gpgcheck => 0;
}
}
31 changes: 20 additions & 11 deletions spec/classes/mongodb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
require 'spec_helper'

describe 'mongodb' do
describe 'mongodb', :type => 'class' do

context 'Unsupported OS' do
let(:facts) {{ :osfamily => 'unsupported' }}
it { expect { should contain_class('mongodb')}.to raise_error(Puppet::Error, /Unsupported OS/ )}
let(:facts) {{ :osfamily => 'unsupported', :operatingsystem => 'UnknownOS' }}
it { is_expected.to raise_error(Puppet::Error,/Unsupported OS/ )}
end

context 'with defaults for all parameters on RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}
it { should contain_class('mongodb') }
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
let :pre_condition do
'include ::mongodb'
end

context 'with defaults for all parameters on Debian' do
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'ubuntu' }}
it { should contain_class('mongodb') }
case facts[:osfamily]
when 'Debian' then
it { should contain_class('mongodb') }
when 'RedHat' then
it { should contain_class('mongodb') }
else
it { is_expected.to raise_error(Puppet::Error,/Unsupported OS/ )}
end
end
end

end
3 changes: 3 additions & 0 deletions spec/defines/mongod_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

context 'with defaults for all parameters on RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}
let :pre_condition do
'include ::mongodb::params'
end
it { should contain_mongodb__mongod('testdb') }
context 'with deactivate_transparent_hugepage set' do
let(:params) {{ :mongod_deactivate_transparent_hugepage => true }}
Expand Down
12 changes: 11 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
require 'puppetlabs_spec_helper/module_spec_helper'
if ENV['COVERAGE'] == 'yes'
RSpec.configure do |c|
c.after(:suite) do
RSpec::Puppet::Coverage.report!
end
end
end

require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts