Skip to content

Commit e399acf

Browse files
samuel.bufefatmcgav
authored andcommitted
added an option to set a custom repository location
1 parent 551b1da commit e399acf

5 files changed

Lines changed: 39 additions & 12 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ class {'::mongodb::server': }->
9292
class {'::mongodb::client': }
9393
```
9494

95+
If you don't want to use the 10gen/MongoDB software repository or the OS packages,
96+
you can point the module to a custom one.
97+
To install MongoDB from a custom repository:
98+
99+
```puppet
100+
class {'::mongodb::globals':
101+
manage_package_repo => true,
102+
repo_location => 'http://example.com/repo'
103+
}->
104+
class {'::mongodb::server': }->
105+
class {'::mongodb::client': }
106+
```
107+
95108
Having a local copy of MongoDB repository (that is managed by your private modules)
96109
you can still enjoy the charms of `mongodb::params` that manage packages.
97110
To disable managing of repository, but still enable managing packages:
@@ -215,6 +228,10 @@ The version of MonogDB to install/manage. This is a simple way of providing
215228
a specific version such as '2.2' or '2.4' for example. If not specified,
216229
the module will use the default for your OS distro.
217230

231+
#####`repo_location`
232+
This setting can be used to override the default MongoDB repository location.
233+
If not specified, the module will use the default repository for your OS distro.
234+
218235
####Class: mongodb::server
219236

220237
Most of the parameters manipulate the mongod.conf file.

manifests/globals.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
$manage_package_repo = undef,
2929
$manage_package = undef,
3030

31+
$repo_location = undef,
3132
$use_enterprise_repo = undef,
3233
) {
3334

3435
# Setup of the repo only makes sense globally, so we are doing it here.
3536
if($manage_package_repo) {
3637
class { '::mongodb::repo':
37-
ensure => present,
38+
ensure => present,
39+
repo_location => $repo_location,
3840
}
3941
}
4042
}

manifests/init.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
$enable_10gen = undef,
3939

4040
$init = $mongodb::params::service_provider,
41-
$location = '',
4241
$packagename = undef,
4342
$version = undef,
4443
$servicename = $mongodb::params::service_name,

manifests/repo.pp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# PRIVATE CLASS: do not use directly
22
class mongodb::repo (
3-
$ensure = $mongodb::params::ensure,
4-
$version = $mongodb::params::version,
3+
$ensure = $mongodb::params::ensure,
4+
$version = $mongodb::params::version,
5+
$repo_location = undef,
56
) inherits mongodb::params {
67
case $::osfamily {
78
'RedHat', 'Linux': {
8-
if $mongodb::globals::use_enterprise_repo == true {
9+
if ($repo_location != undef){
10+
$location = $repo_location
11+
$description = 'MongoDB Custom Repository'
12+
} elsif $mongodb::globals::use_enterprise_repo == true {
913
$location = 'https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/stable/$basearch/'
1014
$description = 'MongoDB Enterprise Repository'
1115
}
@@ -25,14 +29,19 @@
2529
}
2630
$description = 'MongoDB/10gen Repository'
2731
}
32+
2833
class { '::mongodb::repo::yum': }
2934
}
3035

3136
'Debian': {
32-
$location = $::operatingsystem ? {
33-
'Debian' => 'http://downloads-distro.mongodb.org/repo/debian-sysvinit',
34-
'Ubuntu' => 'http://downloads-distro.mongodb.org/repo/ubuntu-upstart',
35-
default => undef
37+
if ($repo_location != undef){
38+
$location = $repo_location
39+
}else{
40+
$location = $::operatingsystem ? {
41+
'Debian' => 'http://downloads-distro.mongodb.org/repo/debian-sysvinit',
42+
'Ubuntu' => 'http://downloads-distro.mongodb.org/repo/ubuntu-upstart',
43+
default => undef
44+
}
3645
}
3746
class { '::mongodb::repo::apt': }
3847
}

manifests/repo/apt.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
include ::apt
77

88
if($::mongodb::repo::ensure == 'present' or $::mongodb::repo::ensure == true) {
9-
apt::source { 'downloads-distro.mongodb.org':
9+
apt::source { 'mongodb':
1010
location => $::mongodb::repo::location,
1111
release => 'dist',
1212
repos => '10gen',
@@ -15,10 +15,10 @@
1515
include_src => false,
1616
}
1717

18-
Apt::Source['downloads-distro.mongodb.org']->Package<|tag == 'mongodb'|>
18+
Apt::Source['mongodb']->Package<|tag == 'mongodb'|>
1919
}
2020
else {
21-
apt::source { 'downloads-distro.mongodb.org':
21+
apt::source { 'mongodb':
2222
ensure => absent,
2323
}
2424
}

0 commit comments

Comments
 (0)