Skip to content

Commit 31e68a9

Browse files
authored
Merge pull request voxpupuli#335 from optiz0r/feature_gentoo
Add support, tests and documentation for Gentoo
2 parents 5aa5a14 + 6ff5077 commit 31e68a9

5 files changed

Lines changed: 95 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This module has been tested to work on the following systems.
2727
* EL 5
2828
* EL 6
2929
* EL 7
30+
* Gentoo (and Sabayon)
3031
* Suse 11
3132
* Ubuntu 10.04
3233
* Ubuntu 12.04

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
validate_bool($use_epel)
128128

129129
# Module compatibility check
130-
$compatible = [ 'Debian', 'RedHat', 'Suse' ]
130+
$compatible = [ 'Debian', 'RedHat', 'Suse', 'Gentoo' ]
131131
if ! ($::osfamily in $compatible) {
132132
fail("Module is not compatible with ${::operatingsystem}")
133133
}

manifests/install.pp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
'RedHat' => "${python}-devel",
2626
'Debian' => "${python}-dev",
2727
'Suse' => "${python}-devel",
28+
'Gentoo' => undef,
2829
}
2930

3031
$dev_ensure = $python::dev ? {
@@ -63,9 +64,11 @@
6364
require => Package['python'],
6465
}
6566

66-
package { 'python-dev':
67-
ensure => $dev_ensure,
68-
name => $pythondev,
67+
if $pythondev {
68+
package { 'python-dev':
69+
ensure => $dev_ensure,
70+
name => $pythondev,
71+
}
6972
}
7073

7174
# Install pip without pip, see https://pip.pypa.io/en/stable/installing/.
@@ -175,9 +178,11 @@
175178
require => Package['python'],
176179
}
177180

178-
package { 'python-dev':
179-
ensure => $dev_ensure,
180-
name => $pythondev,
181+
if $pythondev {
182+
package { 'python-dev':
183+
ensure => $dev_ensure,
184+
name => $pythondev,
185+
}
181186
}
182187

183188
if $::osfamily == 'RedHat' {
@@ -198,19 +203,27 @@
198203
} else {
199204
if $::lsbdistcodename == 'jessie' {
200205
$virtualenv_package = 'virtualenv'
206+
} elsif $::osfamily == 'Gentoo' {
207+
$virtualenv_package = 'virtualenv'
201208
} else {
202209
$virtualenv_package = 'python-virtualenv'
203210
}
204211
}
205212

206213
if $::python::version =~ /^3/ {
214+
$pip_category = undef
207215
$pip_package = 'python3-pip'
216+
} elsif $::osfamily == 'Gentoo' {
217+
$pip_category = 'dev-python'
218+
$pip_package = 'pip'
208219
} else {
220+
$pip_category = undef
209221
$pip_package = 'python-pip'
210222
}
211223

212224
Package <| title == 'pip' |> {
213-
name => $pip_package,
225+
name => $pip_package,
226+
category => $pip_category,
214227
}
215228

216229
Package <| title == 'virtualenv' |> {

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'RedHat' => ['3','27','33'],
1616
'Debian' => ['3', '3.3', '2.7'],
1717
'Suse' => [],
18+
'Gentoo' => ['2.7', '3.3', '3.4', '3.5']
1819
}
1920
$use_epel = true
2021

spec/classes/python_spec.rb

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,76 @@
272272
end
273273
end
274274
end
275+
276+
context "on a Gentoo OS" do
277+
let :facts do
278+
{
279+
:id => 'root',
280+
:kernel => 'Linux',
281+
:lsbdistcodename => 'n/a',
282+
:osfamily => 'Gentoo',
283+
:operatingsystem => 'Gentoo',
284+
:concat_basedir => '/dne',
285+
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
286+
}
287+
end
288+
it { is_expected.to contain_class("python::install") }
289+
# Base debian packages.
290+
it { is_expected.to contain_package("python") }
291+
it { is_expected.to contain_package("pip").with({"category" => "dev-python"}) }
292+
# Basic python packages (from pip)
293+
it { is_expected.to contain_package("virtualenv")}
294+
# Python::Dev
295+
it { is_expected.not_to contain_package("python-dev") }
296+
297+
describe "with manage_gunicorn" do
298+
context "true" do
299+
let (:params) {{ :manage_gunicorn => true }}
300+
it { is_expected.to contain_package("gunicorn") }
301+
end
302+
context "empty args" do
303+
#let (:params) {{ :manage_gunicorn => '' }}
304+
it { is_expected.to contain_package("gunicorn") }
305+
end
306+
context "false" do
307+
let (:params) {{ :manage_gunicorn => false }}
308+
it {is_expected.not_to contain_package("gunicorn")}
309+
end
310+
end
311+
312+
describe "with python::provider" do
313+
context "pip" do
314+
let (:params) {{ :provider => 'pip' }}
315+
316+
it { is_expected.to contain_package("virtualenv").with(
317+
'provider' => 'pip'
318+
)}
319+
it { is_expected.to contain_package("pip").with(
320+
'provider' => 'pip'
321+
)}
322+
end
323+
324+
# python::provider
325+
context "default" do
326+
let (:params) {{ :provider => '' }}
327+
it { is_expected.to contain_package("virtualenv")}
328+
it { is_expected.to contain_package("pip")}
329+
330+
describe "with python::virtualenv" do
331+
context "true" do
332+
let (:params) {{ :provider => '', :virtualenv => 'present' }}
333+
it { is_expected.to contain_package("virtualenv").with_ensure('present') }
334+
end
335+
end
336+
337+
describe "with python::virtualenv" do
338+
context "default/empty" do
339+
let (:params) {{ :provider => '' }}
340+
it { is_expected.to contain_package("virtualenv").with_ensure('absent') }
341+
end
342+
end
343+
end
344+
end
345+
end
346+
275347
end

0 commit comments

Comments
 (0)