Skip to content

Commit

Permalink
Update mongodb to b25bdb3ce7dcb3e60a4427806fe72cc93625de13
Browse files Browse the repository at this point in the history
b25bdb3ce7dcb3e60a4427806fe72cc93625de13 Merge pull request #258 from EmilienM/mongo/provider
2a89243a75ee3be1665f1ab545900afbd882a941 Fix mongodb provider
26c2928f5fae8ed2414356668929db09dacabb68 Merge pull request #257 from EmilienM/mongo/fixshell
e372d3e84c57ff4f256c6303f32da5c60587b668 mongodb: do not add blank parameter in ipv4
202ee76e281ba8f27bbcfd5f39848d2242619cb1 Merge pull request #255 from EmilienM/providers/ipv6
dc31d79e1a39749577ee0385b3bcddc7e7248c41 Merge pull request #256 from hunner/fix_versioncmp
a04f37d689d8425336dd84a54bed34a90d57c829 Fix versioncmp when version is undef
a77d1a191419a3f1f468707aefa69abd689c3e4b (MODULES-2983) Enable IPv6 in mongodb provider
3bcfc75229c4faffe5ccfe9caf1278a54ef0f7cc Merge pull request #237 from erikanderson/normalize_template_spacing
38ceb81e36bbbb844039e12fb8aebb43cb2cef0d Merge pull request #232 from GoozeyX/squashed_forpull
2537fc4dc770c1e1a46567691aa7e7f76961fb52 added yum proxy options
9b9f7571aed4401197437659b31d8d5ac3849e4e Normalize spacing in template

Change-Id: Ib733a303d40c9a32f8247f47c2ddc41c60796cac
  • Loading branch information
jguiditta committed Jan 21, 2016
1 parent 09513f7 commit aaa1a09
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ mod 'module-data',
:git => 'https://github.com/ripienaar/puppet-module-data.git'

mod 'mongodb',
:commit => 'a5d6e5d36fb1007534bca85fd277a678e6c5a2ee',
:commit => 'b25bdb3ce7dcb3e60a4427806fe72cc93625de13',
:git => 'https://github.com/puppetlabs/puppetlabs-mongodb.git'

mod 'mysql',
Expand Down
4 changes: 4 additions & 0 deletions mongodb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased
### Summary
- support setting a proxy for yum repositories with or without user/password authentication

## 2015-06-22 - Release 0.11.0
### Summary

Expand Down
9 changes: 9 additions & 0 deletions mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ the module will use the default for your OS distro.
This setting can be used to override the default MongoDB repository location.
If not specified, the module will use the default repository for your OS distro.

#####`repo_proxy`
This will allow you to set a proxy for your repository in case you are behind a corporate firewall. Currently this is only supported with yum repositories

#####`proxy_username`
This sets the username for the proxyserver, should authentication be required

#####`proxy_password`
This sets the password for the proxyserver, should authentication be required

####Class: mongodb::server

Most of the parameters manipulate the mongod.conf file.
Expand Down
36 changes: 32 additions & 4 deletions mongodb/lib/puppet/provider/mongodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@ def self.get_mongod_conf_file
file
end

def self.ipv6_is_enabled
file = get_mongod_conf_file
config = YAML.load_file(file)
if config.kind_of?(Hash)
ipv6 = config['net.ipv6']
else # It has to be a key-value store
config = {}
File.readlines(file).collect do |line|
k,v = line.split('=')
config[k.rstrip] = v.lstrip.chomp if k and v
end
ipv6 = config['ipv6']
end
ipv6
end

def self.mongo_cmd(db, host, cmd)
if ipv6_is_enabled
out = mongo([db, '--quiet', '--ipv6', '--host', host, '--eval', cmd])
else
out = mongo([db, '--quiet', '--host', host, '--eval', cmd])
end
end

def self.get_conn_string
file = get_mongod_conf_file
# The mongo conf is probably a key-value store, even though 2.6 is
Expand Down Expand Up @@ -55,8 +79,11 @@ def self.get_conn_string

if bindip
first_ip_in_list = bindip.split(',').first
if first_ip_in_list.eql? '0.0.0.0'
case first_ip_in_list
when '0.0.0.0'
ip_real = '127.0.0.1'
when /\[?::0\]?/
ip_real = '::1'
else
ip_real = first_ip_in_list
end
Expand All @@ -80,7 +107,8 @@ def self.db_ismaster
if mongorc_file
cmd_ismaster = mongorc_file + cmd_ismaster
end
out = mongo(['admin', '--quiet', '--host', get_conn_string, '--eval', cmd_ismaster])
db = 'admin'
out = mongo_cmd(db, get_conn_string, cmd_ismaster)
out.gsub!(/ObjectId\(([^)]*)\)/, '\1')
out.gsub!(/ISODate\((.+?)\)/, '\1 ')
out.gsub!(/^Error\:.+/, '')
Expand Down Expand Up @@ -122,9 +150,9 @@ def self.mongo_eval(cmd, db = 'admin', retries = 10, host = nil)
retry_count.times do |n|
begin
if host
out = mongo([db, '--quiet', '--host', host, '--eval', cmd])
out = mongo_cmd(db, host, cmd)
else
out = mongo([db, '--quiet', '--host', get_conn_string, '--eval', cmd])
out = mongo_cmd(db, get_conn_string, cmd)
end
rescue => e
Puppet.debug "Request failed: '#{e.message}' Retry: '#{n}'"
Expand Down
4 changes: 4 additions & 0 deletions mongodb/manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

$manage_package_repo = undef,
$manage_package = undef,
$repo_proxy = undef,
$proxy_username = undef,
$proxy_password = undef,

$repo_location = undef,
$use_enterprise_repo = undef,
Expand All @@ -39,6 +42,7 @@
class { '::mongodb::repo':
ensure => present,
repo_location => $repo_location,
proxy => $repo_proxy,
}
}
}
48 changes: 25 additions & 23 deletions mongodb/manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@

$manage_package = pick($mongodb::globals::manage_package, $mongodb::globals::manage_package_repo, false)

$version = $::mongodb::globals::version

# Amazon Linux's OS Family is 'Linux', operating system 'Amazon'.
case $::osfamily {
'RedHat', 'Linux': {

if $manage_package {
$user = pick($::mongodb::globals::user, 'mongod')
$group = pick($::mongodb::globals::group, 'mongod')
if ($::mongodb::globals::version == undef) {
if ($version == undef) {
$server_package_name = pick($::mongodb::globals::server_package_name, 'mongodb-org-server')
$client_package_name = pick($::mongodb::globals::client_package_name, 'mongodb-org-shell')
$mongos_package_name = pick($::mongodb::globals::mongos_package_name, 'mongodb-org-mongos')
Expand All @@ -38,20 +40,20 @@
$package_ensure_mongos = true
} else {
# check if the version is greater than 2.6
if(versioncmp($::mongodb::globals::version, '2.6.0') >= 0) {
if $version and (versioncmp($version, '2.6.0') >= 0) {
$server_package_name = pick($::mongodb::globals::server_package_name, 'mongodb-org-server')
$client_package_name = pick($::mongodb::globals::client_package_name, 'mongodb-org-shell')
$mongos_package_name = pick($::mongodb::globals::mongos_package_name, 'mongodb-org-mongos')
$package_ensure = $::mongodb::globals::version
$package_ensure_client = $::mongodb::globals::version
$package_ensure_mongos = $::mongodb::globals::version
$package_ensure = $version
$package_ensure_client = $version
$package_ensure_mongos = $version
} else {
$server_package_name = pick($::mongodb::globals::server_package_name, 'mongodb-10gen')
$client_package_name = pick($::mongodb::globals::client_package_name, 'mongodb-10gen')
$mongos_package_name = pick($::mongodb::globals::mongos_package_name, 'mongodb-10gen')
$package_ensure = $::mongodb::globals::version
$package_ensure_client = $::mongodb::globals::version #this is still needed in case they are only installing the client
$package_ensure_mongos = $::mongodb::globals::version
$package_ensure = $version
$package_ensure_client = $version #this is still needed in case they are only installing the client
$package_ensure_mongos = $version
}
}
$service_name = pick($::mongodb::globals::service_name, 'mongod')
Expand All @@ -70,14 +72,14 @@
} else {
# RedHat/CentOS doesn't come with a prepacked mongodb
# so we assume that you are using EPEL repository.
if ($::mongodb::globals::version == undef) {
if ($version == undef) {
$package_ensure = true
$package_ensure_client = true
$package_ensure_mongos = true
} else {
$package_ensure = $::mongodb::globals::version
$package_ensure_client = $::mongodb::globals::version
$package_ensure_mongos = $::mongodb::globals::version
$package_ensure = $version
$package_ensure_client = $version
$package_ensure_mongos = $version
}
$user = pick($::mongodb::globals::user, 'mongodb')
$group = pick($::mongodb::globals::group, 'mongodb')
Expand Down Expand Up @@ -114,7 +116,7 @@
if $manage_package {
$user = pick($::mongodb::globals::user, 'mongodb')
$group = pick($::mongodb::globals::group, 'mongodb')
if ($::mongodb::globals::version == undef) {
if ($version == undef) {
$server_package_name = pick($::mongodb::globals::server_package_name, 'mongodb-org-server')
$client_package_name = pick($::mongodb::globals::client_package_name, 'mongodb-org-shell')
$mongos_package_name = pick($::mongodb::globals::mongos_package_name, 'mongodb-org-mongos')
Expand All @@ -125,21 +127,21 @@
$config = '/etc/mongod.conf'
} else {
# check if the version is greater than 2.6
if(versioncmp($::mongodb::globals::version, '2.6.0') >= 0) {
if $version and (versioncmp($version, '2.6.0') >= 0) {
$server_package_name = pick($::mongodb::globals::server_package_name, 'mongodb-org-server')
$client_package_name = pick($::mongodb::globals::client_package_name, 'mongodb-org-shell')
$mongos_package_name = pick($::mongodb::globals::mongos_package_name, 'mongodb-org-mongos')
$package_ensure = $::mongodb::globals::version
$package_ensure_client = $::mongodb::globals::version
$package_ensure_mongos = $::mongodb::globals::version
$package_ensure = $version
$package_ensure_client = $version
$package_ensure_mongos = $version
$service_name = pick($::mongodb::globals::service_name, 'mongod')
$config = '/etc/mongod.conf'
} else {
$server_package_name = pick($::mongodb::globals::server_package_name, 'mongodb-10gen')
$client_package_name = pick($::mongodb::globals::client_package_name, 'mongodb-10gen')
$mongos_package_name = pick($::mongodb::globals::mongos_package_name, 'mongodb-10gen')
$package_ensure = $::mongodb::globals::version
$package_ensure_client = $::mongodb::globals::version #this is still needed in case they are only installing the client
$package_ensure = $version
$package_ensure_client = $version #this is still needed in case they are only installing the client
$service_name = pick($::mongodb::globals::service_name, 'mongodb')
$config = '/etc/mongodb.conf'
}
Expand All @@ -155,14 +157,14 @@
# I would not recommend to use the prepacked
# mongodb server on Ubuntu 12.04 or Debian 6/7,
# because its really outdated
if ($::mongodb::globals::version == undef) {
if ($version == undef) {
$package_ensure = true
$package_ensure_client = true
$package_ensure_mongos = true
} else {
$package_ensure = $::mongodb::globals::version
$package_ensure_client = $::mongodb::globals::version
$package_ensure_mongos = $::mongodb::globals::version
$package_ensure = $version
$package_ensure_client = $version
$package_ensure_mongos = $version
}
$user = pick($::mongodb::globals::user, 'mongodb')
$group = pick($::mongodb::globals::group, 'mongodb')
Expand Down
11 changes: 7 additions & 4 deletions mongodb/manifests/repo.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# PRIVATE CLASS: do not use directly
class mongodb::repo (
$ensure = $mongodb::params::ensure,
$version = $mongodb::params::version,
$repo_location = undef,
$ensure = $mongodb::params::ensure,
$version = $mongodb::params::version,
$repo_location = undef,
$proxy = undef,
$proxy_username = undef,
$proxy_password = undef,
) inherits mongodb::params {
case $::osfamily {
'RedHat', 'Linux': {
Expand All @@ -13,7 +16,7 @@
$location = 'https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/stable/$basearch/'
$description = 'MongoDB Enterprise Repository'
}
elsif (versioncmp($version, '3.0.0') >= 0) {
elsif $version and (versioncmp($version, '3.0.0') >= 0) {
$mongover = split($version, '[.]')
$location = $::architecture ? {
'x86_64' => "http://repo.mongodb.org/yum/redhat/${::operatingsystemmajrelease}/mongodb-org/${mongover[0]}.${mongover[1]}/x86_64/",
Expand Down
11 changes: 7 additions & 4 deletions mongodb/manifests/repo/yum.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

if($::mongodb::repo::ensure == 'present' or $::mongodb::repo::ensure == true) {
yumrepo { 'mongodb':
descr => $::mongodb::repo::description,
baseurl => $::mongodb::repo::location,
gpgcheck => '0',
enabled => '1',
descr => $::mongodb::repo::description,
baseurl => $::mongodb::repo::location,
gpgcheck => '0',
enabled => '1',
proxy => $::mongodb::repo::proxy,
proxy_username => $::mongodb::repo::proxy_username,
proxy_password => $::mongodb::repo::proxy_password,
}
Yumrepo['mongodb'] -> Package<|tag == 'mongodb'|>
}
Expand Down
2 changes: 1 addition & 1 deletion mongodb/manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
#Pick which config content to use
if $config_content {
$cfg_content = $config_content
} elsif (versioncmp($version, '2.6.0') >= 0) {
} elsif $version and (versioncmp($version, '2.6.0') >= 0) {
# Template uses:
# - $auth
# - $bind_ip
Expand Down
20 changes: 12 additions & 8 deletions mongodb/spec/classes/mongos_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
context 'on Debian with service_manage set to true' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '7.0',
}
end

Expand All @@ -29,8 +30,9 @@
context 'on Debian with service_manage set to false' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '7.0',
}
end

Expand All @@ -50,8 +52,9 @@
context 'on RedHat with service_manage set to true' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.0',
}
end

Expand All @@ -78,8 +81,9 @@
context 'on RedHat with service_manage set to false' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.0',
}
end

Expand Down
39 changes: 34 additions & 5 deletions mongodb/spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
context 'when deploying on Debian' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:lsbdistid => 'Debian',
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '7.0',
:lsbdistid => 'Debian',
}
end

Expand All @@ -19,8 +20,9 @@
context 'when deploying on CentOS' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystem => 'CentOS',
:osfamily => 'RedHat',
:operatingsystem => 'CentOS',
:operatingsystemrelease => '7.0',
}
end

Expand All @@ -29,4 +31,31 @@
}
end

context 'when yumrepo has a proxy set' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.0',
}
end
let :params do
{
:proxy => 'http://proxy-server:8080',
:proxy_username => 'proxyuser1',
:proxy_password => 'proxypassword1',
}
end
it {
is_expected.to contain_class('mongodb::repo::yum')
}
it do
should contain_yumrepo('mongodb').with({
'enabled' => '1',
'proxy' => 'http://proxy-server:8080',
'proxy_username' => 'proxyuser1',
'proxy_password' => 'proxypassword1',
})
end
end
end
Loading

0 comments on commit aaa1a09

Please sign in to comment.