Skip to content

Commit bafcec3

Browse files
authored
Merge pull request #239 from ninech/feature/add_ubuntu_support
Add ubuntu support
2 parents d4455c7 + 1e1d7ee commit bafcec3

File tree

7 files changed

+131
-49
lines changed

7 files changed

+131
-49
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,24 @@ Fedora users can get GlusterFS packages directly from Fedora's repository. Red H
5555
gluster::repo => false
5656
```
5757

58-
For systems using APT, the latest packages of the latest release will be installed by default. Otherwise, specify a version:
58+
For Debian, the latest packages of the latest release will be installed by default. Otherwise, specify a version:
5959

6060
```puppet
6161
class { ::gluster::repo:
6262
version => '3.5.2',
6363
}
6464
```
6565

66+
For Ubuntu, the [Gluster PPA](https://launchpad.net/~gluster) repositories only contain the latest version of each release.
67+
Therefore specify the release to install:
68+
69+
```puppet
70+
class { ::gluster::repo:
71+
release => '10',
72+
}
73+
```
74+
75+
6676
For systems using YUM, the latest package from the 3.8 release branch will be installed. You can specify a specific version and release:
6777

6878
```puppet

manifests/repo.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
}
2828
'Debian': {
2929
class { 'gluster::repo::apt':
30-
version => $version,
30+
version => $version,
31+
release => $release,
3132
}
3233
}
3334
default: { fail("${facts['os']['family']} not yet supported!") }

manifests/repo/apt.pp

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,38 @@
3030
) {
3131
include 'apt'
3232

33-
$repo_key_name = $release ? {
34-
'3.9' => '849512C2CA648EF425048F55C883F50CB2289A17',
35-
'3.10' => 'C784DD0FD61E38B8B1F65E10DAD761554A72C1DF',
36-
'3.11' => 'DE82F0BACC4DB70DBEF95CA65EC2255642304A6E',
37-
'3.12' => '8B7C364430B66F0B084C0B0C55339A4C6A7BD8D4',
38-
'3.13' => '9B5AE8E6FD2581F293104ACC38675E5F30F779AF',
39-
'4.0' => '55F839E173AC06F364120D46FA86EEACB306CEE1',
40-
'4.1' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97',
41-
default => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C',
42-
}
43-
44-
$repo_key_source = "https://download.gluster.org/pub/gluster/glusterfs/${release}/rsa.pub"
45-
46-
# basic sanity check
47-
if $version == 'LATEST' {
48-
$repo_ver = $version
49-
} elsif $version =~ /^\d\.\d+$/ {
50-
$repo_ver = "${version}/LATEST"
51-
} elsif $version =~ /^(\d)\.(\d+)\.(\d+).*$/ {
52-
$repo_ver = "${1}.${2}/${1}.${2}.${3}"
53-
} else {
54-
fail("${version} doesn't make sense for ${facts['os']['name']}!")
33+
$_release = versioncmp($release, '4.1') ? {
34+
1 => $release.match(/\A[^.]*/)[0],
35+
default => $release,
5536
}
5637

5738
# the Gluster repo only supports x86_64 (amd64) and arm64. The Ubuntu PPA also supports armhf and arm64.
5839
case $facts['os']['name'] {
5940
'Debian': {
41+
$repo_key_name = $release ? {
42+
'3.9' => '849512C2CA648EF425048F55C883F50CB2289A17',
43+
'3.10' => 'C784DD0FD61E38B8B1F65E10DAD761554A72C1DF',
44+
'3.11' => 'DE82F0BACC4DB70DBEF95CA65EC2255642304A6E',
45+
'3.12' => '8B7C364430B66F0B084C0B0C55339A4C6A7BD8D4',
46+
'3.13' => '9B5AE8E6FD2581F293104ACC38675E5F30F779AF',
47+
'4.0' => '55F839E173AC06F364120D46FA86EEACB306CEE1',
48+
'4.1' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97',
49+
default => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C',
50+
}
51+
52+
$repo_key_source = "https://download.gluster.org/pub/gluster/glusterfs/${_release}/rsa.pub"
53+
54+
# basic sanity check
55+
if $version == 'LATEST' {
56+
$repo_ver = $version
57+
} elsif $version =~ /^\d\.\d+$/ {
58+
$repo_ver = "${version}/LATEST"
59+
} elsif $version =~ /^(\d)\.(\d+)\.(\d+).*$/ {
60+
$repo_ver = "${1}.${2}/${1}.${2}.${3}"
61+
} else {
62+
fail("${version} doesn't make sense for ${facts['os']['name']}!")
63+
}
64+
6065
case $facts['os']['distro']['codename'] {
6166
'jessie', 'stretch': {
6267
$arch = $facts['os']['architecture'] ? {
@@ -69,11 +74,6 @@
6974
$repo_url = if versioncmp($release, '4.1') < 0 {
7075
"${_repo_base}/01.old-releases/${release}/LATEST/Debian/${facts['os']['distro']['codename']}/${arch}/apt/"
7176
} else {
72-
$_release = if $release == '4.1' {
73-
$release
74-
} else {
75-
$release[0]
76-
}
7777
"${_repo_base}/${_release}/LATEST/Debian/${facts['os']['distro']['codename']}/${arch}/apt/"
7878
}
7979
}
@@ -82,8 +82,27 @@
8282
}
8383
}
8484
}
85+
'Ubuntu': {
86+
$repo_key_name = 'F7C73FCC930AC9F83B387A5613E01B7B3FE869A9'
87+
$repo_key_source = undef
88+
89+
unless $version == 'LATEST' {
90+
fail("Specifying version other than LATEST doesn't make sense for Ubuntu PPA!")
91+
}
92+
$repo_ver = $version
93+
94+
$arch = $facts['os']['architecture'] ? {
95+
'amd64' => 'amd64',
96+
'arm64' => 'arm64',
97+
'armhf' => 'armhf',
98+
'i386' => 'i386',
99+
default => false,
100+
}
101+
102+
$repo_url = "http://ppa.launchpad.net/gluster/glusterfs-${_release}/ubuntu"
103+
}
85104
default: {
86-
fail('gluster::repo::apt currently only works on Debian')
105+
fail('gluster::repo::apt currently only works on Debian and Ubuntu')
87106
}
88107
}
89108

@@ -99,7 +118,7 @@
99118
repos => 'main',
100119
key => {
101120
id => $repo_key_name,
102-
key_source => $repo_key_source,
121+
source => $repo_key_source,
103122
},
104123
pin => $priority,
105124
architecture => $arch,

metadata.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
"11",
4141
"12"
4242
]
43+
},
44+
{
45+
"operatingsystem": "Ubuntu",
46+
"operatingsystemrelease": [
47+
"18.04",
48+
"20.04"
49+
]
4350
}
4451
],
4552
"dependencies": [

spec/classes/client_spec.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,19 @@
6969
}
7070
end
7171

72-
it 'includes gluster::install with version 3.6.1' do
73-
is_expected.to create_class('gluster::install').with(
74-
repo: true,
75-
client_package: 'glusterfs-client',
76-
version: '3.6.1'
77-
)
72+
case facts[:os][:name]
73+
when 'Debian'
74+
it 'includes gluster::install with version 3.6.1' do
75+
is_expected.to create_class('gluster::install').with(
76+
repo: true,
77+
client_package: 'glusterfs-client',
78+
version: '3.6.1'
79+
)
80+
end
81+
when 'Ubuntu'
82+
it 'does not install' do
83+
is_expected.to compile.and_raise_error(%r{Specifying version other than LATEST doesn't make sense for Ubuntu PPA!})
84+
end
7885
end
7986
end
8087
context 'when repo is false' do

spec/classes/repo_apt_spec.rb

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
it { is_expected.to contain_class('gluster::repo::apt') }
1111
it { is_expected.to compile.with_all_deps }
1212
it 'installs' do
13+
location = {
14+
'Debian' => "https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/",
15+
'Ubuntu' => 'http://ppa.launchpad.net/gluster/glusterfs-7/ubuntu',
16+
}
1317
is_expected.to contain_apt__source('glusterfs-LATEST').with(
1418
repos: 'main',
1519
release: facts[:lsbdistcodename].to_s,
16-
location: "https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/"
20+
location: location[facts[:os]['name']]
1721
)
1822
end
1923
end
@@ -39,10 +43,14 @@
3943
end
4044

4145
it 'installs' do
46+
location = {
47+
'Debian' => "https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/",
48+
'Ubuntu' => 'http://ppa.launchpad.net/gluster/glusterfs-7/ubuntu',
49+
}
4250
is_expected.to contain_apt__source('glusterfs-LATEST').with(
4351
repos: 'main',
4452
release: facts[:lsbdistcodename].to_s,
45-
location: "https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/",
53+
location: location[facts[:os]['name']],
4654
pin: '700'
4755
)
4856
end
@@ -56,14 +64,25 @@
5664
end
5765

5866
it 'installs' do
67+
location = {
68+
'Debian' => "https://download.gluster.org/pub/gluster/glusterfs/4.1/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/",
69+
'Ubuntu' => 'http://ppa.launchpad.net/gluster/glusterfs-4.1/ubuntu',
70+
}
71+
key = {
72+
'Debian' => {
73+
'id' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97',
74+
'source' => 'https://download.gluster.org/pub/gluster/glusterfs/4.1/rsa.pub',
75+
},
76+
'Ubuntu' => {
77+
'id' => 'F7C73FCC930AC9F83B387A5613E01B7B3FE869A9',
78+
'source' => nil,
79+
},
80+
}
5981
is_expected.to contain_apt__source('glusterfs-LATEST').with(
6082
repos: 'main',
6183
release: facts[:lsbdistcodename].to_s,
62-
key: {
63-
'id' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97',
64-
'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/4.1/rsa.pub'
65-
},
66-
location: "https://download.gluster.org/pub/gluster/glusterfs/4.1/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/"
84+
key: key[facts[:os]['name']],
85+
location: location[facts[:os]['name']]
6786
)
6887
end
6988
end
@@ -76,14 +95,25 @@
7695
end
7796

7897
it 'installs' do
98+
location = {
99+
'Debian' => "https://download.gluster.org/pub/gluster/glusterfs/01.old-releases/3.12/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/",
100+
'Ubuntu' => 'http://ppa.launchpad.net/gluster/glusterfs-3.12/ubuntu',
101+
}
102+
key = {
103+
'Debian' => {
104+
'id' => '8B7C364430B66F0B084C0B0C55339A4C6A7BD8D4',
105+
'source' => 'https://download.gluster.org/pub/gluster/glusterfs/3.12/rsa.pub',
106+
},
107+
'Ubuntu' => {
108+
'id' => 'F7C73FCC930AC9F83B387A5613E01B7B3FE869A9',
109+
'source' => nil,
110+
},
111+
}
79112
is_expected.to contain_apt__source('glusterfs-LATEST').with(
80113
repos: 'main',
81114
release: facts[:lsbdistcodename].to_s,
82-
key: {
83-
'id' => '8B7C364430B66F0B084C0B0C55339A4C6A7BD8D4',
84-
'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/3.12/rsa.pub'
85-
},
86-
location: "https://download.gluster.org/pub/gluster/glusterfs/01.old-releases/3.12/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/"
115+
key: key[facts[:os]['name']],
116+
location: location[facts[:os]['name']]
87117
)
88118
end
89119
end

spec/setup_acceptance_node.pp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if $facts['os']['name'] == 'Ubuntu' {
2+
# Needed for facter to fetch facts used by the postgresql module
3+
if versioncmp($facts['facterversion'], '4.0.0') <= 0 {
4+
package{ 'lsb-release':
5+
ensure => present,
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)