Skip to content

Commit

Permalink
Merge pull request #335 from optiz0r/feature_gentoo
Browse files Browse the repository at this point in the history
Add support, tests and documentation for Gentoo
  • Loading branch information
ghoneycutt authored Oct 12, 2016
2 parents 5aa5a14 + 6ff5077 commit 31e68a9
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This module has been tested to work on the following systems.
* EL 5
* EL 6
* EL 7
* Gentoo (and Sabayon)
* Suse 11
* Ubuntu 10.04
* Ubuntu 12.04
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
validate_bool($use_epel)

# Module compatibility check
$compatible = [ 'Debian', 'RedHat', 'Suse' ]
$compatible = [ 'Debian', 'RedHat', 'Suse', 'Gentoo' ]
if ! ($::osfamily in $compatible) {
fail("Module is not compatible with ${::operatingsystem}")
}
Expand Down
27 changes: 20 additions & 7 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'RedHat' => "${python}-devel",
'Debian' => "${python}-dev",
'Suse' => "${python}-devel",
'Gentoo' => undef,
}

$dev_ensure = $python::dev ? {
Expand Down Expand Up @@ -63,9 +64,11 @@
require => Package['python'],
}

package { 'python-dev':
ensure => $dev_ensure,
name => $pythondev,
if $pythondev {
package { 'python-dev':
ensure => $dev_ensure,
name => $pythondev,
}
}

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

package { 'python-dev':
ensure => $dev_ensure,
name => $pythondev,
if $pythondev {
package { 'python-dev':
ensure => $dev_ensure,
name => $pythondev,
}
}

if $::osfamily == 'RedHat' {
Expand All @@ -198,19 +203,27 @@
} else {
if $::lsbdistcodename == 'jessie' {
$virtualenv_package = 'virtualenv'
} elsif $::osfamily == 'Gentoo' {
$virtualenv_package = 'virtualenv'
} else {
$virtualenv_package = 'python-virtualenv'
}
}

if $::python::version =~ /^3/ {
$pip_category = undef
$pip_package = 'python3-pip'
} elsif $::osfamily == 'Gentoo' {
$pip_category = 'dev-python'
$pip_package = 'pip'
} else {
$pip_category = undef
$pip_package = 'python-pip'
}

Package <| title == 'pip' |> {
name => $pip_package,
name => $pip_package,
category => $pip_category,
}

Package <| title == 'virtualenv' |> {
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'RedHat' => ['3','27','33'],
'Debian' => ['3', '3.3', '2.7'],
'Suse' => [],
'Gentoo' => ['2.7', '3.3', '3.4', '3.5']
}
$use_epel = true

Expand Down
72 changes: 72 additions & 0 deletions spec/classes/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,76 @@
end
end
end

context "on a Gentoo OS" do
let :facts do
{
:id => 'root',
:kernel => 'Linux',
:lsbdistcodename => 'n/a',
:osfamily => 'Gentoo',
:operatingsystem => 'Gentoo',
:concat_basedir => '/dne',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
it { is_expected.to contain_class("python::install") }
# Base debian packages.
it { is_expected.to contain_package("python") }
it { is_expected.to contain_package("pip").with({"category" => "dev-python"}) }
# Basic python packages (from pip)
it { is_expected.to contain_package("virtualenv")}
# Python::Dev
it { is_expected.not_to contain_package("python-dev") }

describe "with manage_gunicorn" do
context "true" do
let (:params) {{ :manage_gunicorn => true }}
it { is_expected.to contain_package("gunicorn") }
end
context "empty args" do
#let (:params) {{ :manage_gunicorn => '' }}
it { is_expected.to contain_package("gunicorn") }
end
context "false" do
let (:params) {{ :manage_gunicorn => false }}
it {is_expected.not_to contain_package("gunicorn")}
end
end

describe "with python::provider" do
context "pip" do
let (:params) {{ :provider => 'pip' }}

it { is_expected.to contain_package("virtualenv").with(
'provider' => 'pip'
)}
it { is_expected.to contain_package("pip").with(
'provider' => 'pip'
)}
end

# python::provider
context "default" do
let (:params) {{ :provider => '' }}
it { is_expected.to contain_package("virtualenv")}
it { is_expected.to contain_package("pip")}

describe "with python::virtualenv" do
context "true" do
let (:params) {{ :provider => '', :virtualenv => 'present' }}
it { is_expected.to contain_package("virtualenv").with_ensure('present') }
end
end

describe "with python::virtualenv" do
context "default/empty" do
let (:params) {{ :provider => '' }}
it { is_expected.to contain_package("virtualenv").with_ensure('absent') }
end
end
end
end
end

end

0 comments on commit 31e68a9

Please sign in to comment.