Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,11 @@ Create a Python3 virtualenv using pyvenv.
#####

```puppet
class { 'python':
version => 'system',
venv => 'present',
}

python::pyvenv { '/var/www/project1' :
ensure => present,
version => 'system',
Expand Down
3 changes: 2 additions & 1 deletion examples/pyvenv.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class { 'python':
pip => false,
pip => 'absent',
venv => 'present',
version => '3',
}

Expand Down
6 changes: 5 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
#
class python::install {
$python = $python::version ? {
'system' => 'python',
'system' => $facts['os']['family'] ? {
'Debian' => 'python3',
'RedHat' => 'python3',
default => 'python',
},
'pypy' => 'pypy',
/\A(python[23]\.[0-9]+)/ => $1,
/\A(python)?([0-9]+)/ => "python${2}",
Expand Down
5 changes: 5 additions & 0 deletions manifests/pyvenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# @param python_path Optionally specify python path for creation of virtualenv
#
# @example
# class { 'python':
# version => 'system',
# venv => 'present',
# }
#
# python::pyvenv { '/var/www/project1' :
# ensure => present,
# version => 'system',
Expand Down
17 changes: 17 additions & 0 deletions spec/acceptance/pyvenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,21 @@ class { 'python':
its(:stdout) { is_expected.to match %r{agent.* 0\.1\.2} }
end
end

context "with version => 'system'" do
it 'works with no errors' do
pp = <<-PUPPET
class { 'python':
version => 'system',
venv => 'present',
}
python::pyvenv { '/opt/regress700':
ensure => 'present',
}
PUPPET

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
end
end
16 changes: 16 additions & 0 deletions spec/classes/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@
it { is_expected.to contain_package('python-venv').with(ensure: 'present') } unless facts[:os]['family'] == 'RedHat'
end

if facts[:os]['family'] == 'Debian'
context "with version => 'system' on Debian family" do
let(:params) { { version: 'system', venv: 'present' } }

it { is_expected.to contain_package('python-venv').with(name: 'python3-venv', ensure: 'present') }
end
end

if %w[Debian RedHat].include?(facts[:os]['family'])
context "with version => 'system'" do
let(:params) { { version: 'system' } }

it { is_expected.to contain_package('python').with(name: 'python3') }
end
end

case facts[:os]['family']
when 'Debian'

Expand Down
Loading