Skip to content

Commit a0b6ab7

Browse files
committed
open-prs - Fix duplicate declaration for python-venv package
Fixes voxpupuli#517.
1 parent 432708e commit a0b6ab7

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

manifests/pyvenv.pp

+5-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@
3232
$path = [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ],
3333
$environment = [],
3434
) {
35-
3635
include python
3736

3837
if $ensure == 'present' {
3938
$python_version = $version ? {
40-
'system' => $facts['python3_version'],
41-
default => $version,
39+
'system' => $facts['python3_version'],
40+
default => $version,
4241
}
4342

4443
$python_version_parts = split($python_version, '[.]')
@@ -50,11 +49,10 @@
5049
case $facts['lsbdistcodename'] {
5150
'xenial','bionic','cosmic','disco',
5251
'jessie','stretch','buster': {
53-
ensure_packages ($python3_venv_package, {
54-
before => File[$venv_dir],
55-
})
52+
ensure_packages ($python3_venv_package)
53+
Package[$python3_venv_package] -> File[$venv_dir]
5654
}
57-
default: {}
55+
default: {}
5856
}
5957
}
6058

spec/classes/python_spec.rb

+22
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@
7272
end
7373
end
7474

75+
describe 'with python::python_pyvenvs' do
76+
context 'with two pyenvs' do
77+
let(:params) do
78+
{
79+
python_pyvenvs: {
80+
'/opt/env1' => {
81+
version: '3.8'
82+
},
83+
'/opt/env2' => {
84+
version: '3.8'
85+
}
86+
}
87+
}
88+
end
89+
90+
it { is_expected.to compile }
91+
92+
it { is_expected.to contain_python__pyvenv('/opt/env1').with_ensure('present') }
93+
it { is_expected.to contain_python__pyvenv('/opt/env2').with_ensure('present') }
94+
end
95+
end
96+
7597
describe 'with manage_gunicorn' do
7698
context 'true' do
7799
let(:params) { { manage_gunicorn: true } }

spec/defines/pyvenv_spec.rb

+8-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
'/opt/env'
1414
end
1515

16-
it {
17-
is_expected.to contain_file('/opt/env')
18-
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env')
19-
}
16+
context 'with default parameters' do
17+
it { is_expected.to contain_file('/opt/env') }
18+
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env') }
19+
20+
if %w[xenial bionic cosmic disco jessie stretch buster].include?(facts[:lsbdistcodename])
21+
it { is_expected.to contain_package('python3.5-venv').that_comes_before('File[/opt/env]') }
22+
end
23+
end
2024

2125
describe 'when ensure' do
2226
context 'is absent' do

0 commit comments

Comments
 (0)