Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate declaration for python-venv package #518

Merged
Merged
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
12 changes: 5 additions & 7 deletions manifests/pyvenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
$path = [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ],
$environment = [],
) {

include python

if $ensure == 'present' {
$python_version = $version ? {
'system' => $facts['python3_version'],
default => $version,
'system' => $facts['python3_version'],
default => $version,
}

$python_version_parts = split($python_version, '[.]')
Expand All @@ -50,11 +49,10 @@
case $facts['lsbdistcodename'] {
'xenial','bionic','cosmic','disco',
'jessie','stretch','buster': {
ensure_packages ($python3_venv_package, {
before => File[$venv_dir],
})
ensure_packages ($python3_venv_package)
Package[$python3_venv_package] -> File[$venv_dir]
}
default: {}
default: {}
}
}

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

describe 'with python::python_pyvenvs' do
context 'with two pyenvs' do
let(:params) do
{
python_pyvenvs: {
'/opt/env1' => {
version: '3.8'
},
'/opt/env2' => {
version: '3.8'
}
}
}
end

it { is_expected.to compile }

it { is_expected.to contain_python__pyvenv('/opt/env1').with_ensure('present') }
it { is_expected.to contain_python__pyvenv('/opt/env2').with_ensure('present') }
end
end

describe 'with manage_gunicorn' do
context 'true' do
let(:params) { { manage_gunicorn: true } }
Expand Down
12 changes: 8 additions & 4 deletions spec/defines/pyvenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
'/opt/env'
end

it {
is_expected.to contain_file('/opt/env')
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env')
}
context 'with default parameters' do
it { is_expected.to contain_file('/opt/env') }
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env') }

if %w[xenial bionic cosmic disco jessie stretch buster].include?(facts[:lsbdistcodename])
it { is_expected.to contain_package('python3.5-venv').that_comes_before('File[/opt/env]') }
end
end

describe 'when ensure' do
context 'is absent' do
Expand Down