Skip to content

Commit 2e6001a

Browse files
fbrehmbastelfreak
andauthored
Add support for Suse Linux (#624)
* Version bump to 2.3.2 * Version bump to 2.3.3 * Updating module version * Adding manifests/repo/zypper.pp * Support of Suse zypper repos * Fixing manifests/repo.pp * Version bump to 4.0.0.2 * Version bump to 4.0.1-rc0 * Setting version to 4.0.0 * Adding SLES 12 and 15 as a supported operating system * Setting supported version for Enterprise Linux to 3.0 * Adding dependency to puppet/zypprepo * Updating spec test for Suse * Fixing spec tests for Suse * Style changes * Fixing package in manifests/mongos/params.pp for Suse * Fixing config in manifests/mongos/config.pp for Suse * Making fork on package purge for Suse * Fixing Repo base_url for zypper * Fixing spec/classes/repo_spec.rb for Suse * Changing two elsifs to one * Simplifying logic in manifests/repo.pp * Adding puppet strings documentation to manifests/repo/zypper.pp and declaring it for private. * Update metadata.json Update metadata.json - lower version boundary Co-authored-by: Tim Meusel <tim@bastelfreak.de> * Make the linter happy Co-authored-by: Tim Meusel <tim@bastelfreak.de>
1 parent 61b00f2 commit 2e6001a

File tree

10 files changed

+86
-10
lines changed

10 files changed

+86
-10
lines changed

.fixtures.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ fixtures:
33
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
44
"apt": "git://github.com/puppetlabs/puppetlabs-apt.git"
55
"systemd": "https://github.com/voxpupuli/puppet-systemd.git"
6+
"zypprepo": "https://github.com/voxpupuli/puppet-zypprepo.git"
67
yumrepo_core:
78
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
89
puppet_version: ">= 6.0.0"

manifests/mongos/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
}
3939

4040
if $service_manage {
41-
if $facts['os']['family'] == 'RedHat' {
41+
if $facts['os']['family'] == 'RedHat' or $facts['os']['family'] == 'Suse' {
4242
file { '/etc/sysconfig/mongos' :
4343
ensure => $ensure,
4444
owner => 'root',

manifests/mongos/install.pp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
$package_ensure = $mongodb::mongos::package_ensure,
44
$package_name = $mongodb::mongos::package_name,
55
) {
6+
if $facts['os']['family'] == 'Suse' and $package_ensure == 'purged' {
7+
$_package_ensure = 'absent'
8+
} else {
9+
$_package_ensure = $package_ensure
10+
}
11+
612
unless defined(Package[$package_name]) {
713
package { 'mongodb_mongos':
8-
ensure => $package_ensure,
14+
ensure => $_package_ensure,
915
name => $package_name,
1016
tag => 'mongodb_package',
1117
}

manifests/mongos/params.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$package_ensure = pick($version, 'present')
88
if $manage_package {
99
$package_name = "mongodb-${mongodb::globals::edition}-mongos"
10-
} elsif $facts['os']['family'] == 'RedHat' {
10+
} elsif $facts['os']['family'] in ['RedHat', 'Suse'] {
1111
$package_name = "mongodb-${mongodb::globals::edition}-mongos"
1212
} else {
1313
$package_name = 'mongodb-server'

manifests/repo.pp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@
3030
contain mongodb::repo::yum
3131
}
3232

33+
'Suse': {
34+
if $repo_location {
35+
$location = $repo_location
36+
$description = 'MongoDB Custom Repository'
37+
} elsif $version == undef or versioncmp($version, '3.2.0') < 0 {
38+
fail('Package repositories for versions older than 3.2 are unsupported')
39+
} else {
40+
$mongover = split($version, '[.]')
41+
$location = "https://repo.mongodb.org/zypper/suse/\$releasever_major/mongodb-org/${mongover[0]}.${mongover[1]}/\$basearch/"
42+
$description = 'MongoDB Repository'
43+
}
44+
45+
contain mongodb::repo::zypper
46+
}
47+
3348
'Debian': {
3449
if $repo_location != undef {
3550
$location = $repo_location
@@ -74,7 +89,7 @@
7489

7590
default: {
7691
if($ensure == 'present' or $ensure == true) {
77-
fail("Unsupported managed repository for osfamily: ${facts['os']['family']}, operatingsystem: ${facts['os']['name']}, module ${module_name} currently only supports managing repos for osfamily RedHat, Debian and Ubuntu")
92+
fail("Unsupported managed repository for osfamily: ${facts['os']['family']}, operatingsystem: ${facts['os']['name']}, module ${module_name} currently only supports managing repos for osfamily RedHat, Suse, Debian and Ubuntu")
7893
}
7994
}
8095
}

manifests/repo/zypper.pp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# PRIVATE CLASS: do not use directly
2+
#
3+
# @summary This is a repo class for zypper
4+
#
5+
# This is a private class and cannot be used from outside this module.
6+
#
7+
# @author Frank Brehm <frank@brehm-online.com>
8+
#
9+
# @api private
10+
#
11+
class mongodb::repo::zypper inherits mongodb::repo {
12+
# We try to follow/reproduce the instruction
13+
# http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/
14+
15+
assert_private()
16+
17+
if $mongodb::repo::ensure == 'present' or $mongodb::repo::ensure == true {
18+
zypprepo { 'mongodb':
19+
descr => $mongodb::repo::description,
20+
baseurl => $mongodb::repo::location,
21+
gpgcheck => '0',
22+
enabled => '1',
23+
}
24+
Zypprepo['mongodb'] -> Package<| tag == 'mongodb_package' |>
25+
}
26+
else {
27+
zypprepo { 'mongodb':
28+
ensure => absent,
29+
}
30+
}
31+
}

metadata.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
"18.04",
3434
"20.04"
3535
]
36+
},
37+
{
38+
"operatingsystem": "SLES",
39+
"operatingsystemrelease": [
40+
"12",
41+
"15"
42+
]
3643
}
3744
],
3845
"requirements": [
@@ -53,6 +60,10 @@
5360
{
5461
"name": "puppet/systemd",
5562
"version_requirement": ">= 2.5.1 < 4.0.0"
63+
},
64+
{
65+
"name": "puppet/zypprepo",
66+
"version_requirement": ">= 4.0.1 < 6.0.0"
5667
}
5768
]
5869
}

spec/classes/mongos_spec.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
it { is_expected.to contain_class('mongodb::mongos::config') }
3434

3535
case facts[:osfamily]
36-
when 'RedHat'
36+
when 'RedHat', 'Suse'
3737
expected_content = <<-CONFIG
3838
configdb = 127.0.0.1:27019
3939
fork = true
@@ -54,7 +54,7 @@
5454
# service
5555
it { is_expected.to contain_class('mongodb::mongos::service') }
5656

57-
if facts[:osfamily] == 'RedHat'
57+
if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'Suse'
5858
it { is_expected.to contain_file('/etc/sysconfig/mongos') }
5959
else
6060
it { is_expected.not_to contain_file('/etc/sysconfig/mongos') }
@@ -119,19 +119,23 @@
119119

120120
# install
121121
it { is_expected.to contain_class('mongodb::mongos::install') }
122-
it { is_expected.to contain_package('mongodb_mongos').with_ensure('purged') }
122+
if facts[:osfamily] == 'Suse'
123+
it { is_expected.to contain_package('mongodb_mongos').with_ensure('absent') }
124+
else
125+
it { is_expected.to contain_package('mongodb_mongos').with_ensure('purged') }
126+
end
123127

124128
# config
125129
it { is_expected.to contain_class('mongodb::mongos::config') }
126130

127131
case facts[:osfamily]
128-
when 'RedHat'
132+
when 'RedHat', 'Suse'
129133
it { is_expected.to contain_file('/etc/mongos.conf').with_ensure('absent') }
130134
when 'Debian'
131135
it { is_expected.to contain_file('/etc/mongodb-shard.conf').with_ensure('absent') }
132136
end
133137

134-
if facts[:osfamily] == 'RedHat'
138+
if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'Suse'
135139
it { is_expected.to contain_file('/etc/sysconfig/mongos').with_ensure('absent') }
136140
else
137141
it { is_expected.not_to contain_file('/etc/sysconfig/mongos') }

spec/classes/repo_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
is_expected.to contain_yumrepo('mongodb').
2626
with_baseurl('https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/$basearch/')
2727
end
28+
when 'Suse'
29+
it { is_expected.to contain_class('mongodb::repo::zypper') }
30+
it do
31+
is_expected.to contain_zypprepo('mongodb').
32+
with_baseurl('https://repo.mongodb.org/zypper/suse/$releasever_major/mongodb-org/3.6/$basearch/')
33+
end
2834
when 'Debian'
2935
it { is_expected.to contain_class('mongodb::repo::apt') }
3036
case facts[:operatingsystem]
@@ -66,6 +72,8 @@
6672
with_proxy_username('proxyuser1').
6773
with_proxy_password('proxypassword1')
6874
end
75+
when 'Suse'
76+
it { is_expected.to contain_class('mongodb::repo::zypper') }
6977
when 'Debian'
7078
it { is_expected.to contain_class('mongodb::repo::apt') }
7179
else

spec/classes/server_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
describe 'with defaults' do
4242
it_behaves_like 'server classes'
4343

44-
if facts[:os]['family'] == 'RedHat'
44+
if facts[:os]['family'] == 'RedHat' || facts[:os]['family'] == 'Suse'
4545
it { is_expected.to contain_package('mongodb_server').with_ensure('present').with_name('mongodb-org-server').with_tag('mongodb_package') }
4646
elsif facts[:os]['release']['major'] =~ %r{(10)}
4747
it { is_expected.to contain_package('mongodb_server').with_ensure('4.4.8').with_name('mongodb-org-server').with_tag('mongodb_package') }

0 commit comments

Comments
 (0)