Skip to content

Commit

Permalink
Set default python to 3; except for CentOS 7
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Dec 15, 2020
1 parent d9c51a8 commit b4aa545
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 29 deletions.
6 changes: 4 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ Data type: `Python::Version`

Python version to use.

Default value: `'system'`
Default value: `$python::version`

##### `requirements`

Expand Down Expand Up @@ -1099,6 +1099,8 @@ Default value: ``true``
Data type: `Boolean`

Include distribute in the virtualenv
Forced to `false` for Ubuntu 18.04 and 20.04
Forced to `false` for RedHat based systems

Default value: ``true``

Expand Down Expand Up @@ -1192,7 +1194,7 @@ Default value: `''`

##### `virtualenv`

Data type: `Optional[Stdlib::Absolutepath]`
Data type: `Optional[String[1]]`



Expand Down
6 changes: 2 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@
default => 'gunicorn',
}

if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' {
$version = '3'
} elsif $facts['os']['release']['major'] == '20.04' {
$version = '3'
if $facts['os']['family'] == 'RedHat' and Integer($facts['os']['release']['major']) == 7 {
$version = 'system'
} else {
$version = 'system'
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#
define python::virtualenv (
Python::Package::Ensure $ensure = 'present',
Python::Version $version = 'system',
Python::Version $version = $python::version,
Variant[Boolean,Stdlib::Absolutepath] $requirements = false,
Boolean $systempkgs = false,
Stdlib::Absolutepath $venv_dir = $name,
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/pyvenv_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper_acceptance'

describe 'python::pyvenv defined resource' do
describe 'python::pyvenv defined resource with python 3' do
context 'minimal parameters' do
# Using puppet_apply as a helper
it 'works with no errors' do
Expand Down
21 changes: 0 additions & 21 deletions spec/acceptance/virtualenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
# Using puppet_apply as a helper
it 'works with no errors' do
pp = <<-EOS
$version = '3'
class { 'python' :
version => $version,
pip => 'present',
virtualenv => 'present',
}
-> python::virtualenv { 'venv' :
ensure => 'present',
version => $version,
systempkgs => false,
distribute => false,
venv_dir => '/opt/venv',
Expand All @@ -32,16 +28,12 @@ class { 'python' :

it 'maintains pip version' do
pp = <<-EOS
$version = '3'
class { 'python' :
version => $version,
pip => 'present',
virtualenv => 'present',
}
-> python::virtualenv { 'venv' :
ensure => 'present',
version => $version,
systempkgs => false,
venv_dir => '/opt/venv2',
}
Expand All @@ -58,16 +50,12 @@ class { 'python' :

it 'works with ensure=>latest' do
pp = <<-EOS
$version = '3'
class { 'python' :
version => $version,
pip => 'present',
virtualenv => 'present',
}
-> python::virtualenv { 'venv' :
ensure => 'present',
version => $version,
systempkgs => false,
venv_dir => '/opt/venv3',
}
Expand All @@ -86,7 +74,6 @@ class { 'python' :

it 'works with ensure=>latest for package with underscore in its name' do
pp = <<-EOS
$version = '3'
class { 'python' :
version => $version,
Expand Down Expand Up @@ -114,19 +101,15 @@ class { 'python' :

it 'works with editable=>true' do
pp = <<-EOS
$version = '3'
package{ 'git' :
ensure => 'present',
}
-> class { 'python' :
version => $version,
pip => 'present',
virtualenv => 'present',
}
-> python::virtualenv { 'venv' :
ensure => 'present',
version => $version,
systempkgs => false,
venv_dir => '/opt/venv5',
}
Expand All @@ -145,16 +128,12 @@ class { 'python' :

it 'works with == in pkgname' do
pp = <<-EOS
$version = '3'
class { 'python' :
version => $version,
pip => 'present',
virtualenv => 'present',
}
-> python::virtualenv { 'venv' :
ensure => 'present',
version => $version,
systempkgs => false,
venv_dir => '/opt/venv6',
}
Expand Down

0 comments on commit b4aa545

Please sign in to comment.