Skip to content

Commit 3fc880c

Browse files
authored
Merge pull request #752 from bwitt/fix-venv-package
Install the right venv package on Debian and RedHat family
2 parents 2f31b66 + 3e0c35d commit 3fc880c

6 files changed

Lines changed: 50 additions & 2 deletions

File tree

‎REFERENCE.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,11 @@ Create a Python3 virtualenv using pyvenv.
894894
#####
895895

896896
```puppet
897+
class { 'python':
898+
version => 'system',
899+
venv => 'present',
900+
}
901+
897902
python::pyvenv { '/var/www/project1' :
898903
ensure => present,
899904
version => 'system',

‎examples/pyvenv.pp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class { 'python':
2-
pip => false,
2+
pip => 'absent',
3+
venv => 'present',
34
version => '3',
45
}
56

‎manifests/install.pp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
#
77
class python::install {
88
$python = $python::version ? {
9-
'system' => 'python',
9+
'system' => $facts['os']['family'] ? {
10+
'Debian' => 'python3',
11+
'RedHat' => 'python3',
12+
default => 'python',
13+
},
1014
'pypy' => 'pypy',
1115
/\A(python[23]\.[0-9]+)/ => $1,
1216
/\A(python)?([0-9]+)/ => "python${2}",

‎manifests/pyvenv.pp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
# @param python_path Optionally specify python path for creation of virtualenv
1515
#
1616
# @example
17+
# class { 'python':
18+
# version => 'system',
19+
# venv => 'present',
20+
# }
21+
#
1722
# python::pyvenv { '/var/www/project1' :
1823
# ensure => present,
1924
# version => 'system',

‎spec/acceptance/pyvenv_spec.rb‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,21 @@ class { 'python':
235235
its(:stdout) { is_expected.to match %r{agent.* 0\.1\.2} }
236236
end
237237
end
238+
239+
context "with version => 'system'" do
240+
it 'works with no errors' do
241+
pp = <<-PUPPET
242+
class { 'python':
243+
version => 'system',
244+
venv => 'present',
245+
}
246+
python::pyvenv { '/opt/regress700':
247+
ensure => 'present',
248+
}
249+
PUPPET
250+
251+
apply_manifest(pp, catch_failures: true)
252+
apply_manifest(pp, catch_changes: true)
253+
end
254+
end
238255
end

‎spec/classes/python_spec.rb‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@
6363
it { is_expected.to contain_package('python-venv').with(ensure: 'present') } unless facts[:os]['family'] == 'RedHat'
6464
end
6565

66+
if facts[:os]['family'] == 'Debian'
67+
context "with version => 'system' on Debian family" do
68+
let(:params) { { version: 'system', venv: 'present' } }
69+
70+
it { is_expected.to contain_package('python-venv').with(name: 'python3-venv', ensure: 'present') }
71+
end
72+
end
73+
74+
if %w[Debian RedHat].include?(facts[:os]['family'])
75+
context "with version => 'system'" do
76+
let(:params) { { version: 'system' } }
77+
78+
it { is_expected.to contain_package('python').with(name: 'python3') }
79+
end
80+
end
81+
6682
case facts[:os]['family']
6783
when 'Debian'
6884

0 commit comments

Comments
 (0)