diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index baaba1a3..eed7f4c4 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -37,14 +37,14 @@ if $ensure == 'present' { $python_version = $version ? { - 'system' => $::python3_version, + 'system' => $facts['python3_version'], default => $version, } # Debian splits the venv module into a seperate package if ( $facts['os']['family'] == 'Debian'){ $python3_venv_package="python${python_version}-venv" - case $facts['os']['distro']['codename'] { + case $facts['lsbdistcodename'] { 'xenial','bionic','cosmic','disco', 'jessie','stretch','buster': { package {$python3_venv_package: @@ -56,7 +56,7 @@ } # pyvenv is deprecated since 3.6 and will be removed in 3.8 - if (versioncmp($::python3_version, '3.6') >=0) { + if (versioncmp($facts['python3_version'], '3.6') >=0) { $virtualenv_cmd = "${python::exec_prefix}python${python_version} -m venv" } else { $virtualenv_cmd = "${python::exec_prefix}pyvenv-${python_version}" diff --git a/spec/default_module_facts.yml b/spec/default_module_facts.yml new file mode 100644 index 00000000..3f8d54e2 --- /dev/null +++ b/spec/default_module_facts.yml @@ -0,0 +1,3 @@ +--- +python_version: "2.7" +python3_version: ~ diff --git a/spec/defines/pyvenv_spec.rb b/spec/defines/pyvenv_spec.rb index 285a0de5..d3143f51 100644 --- a/spec/defines/pyvenv_spec.rb +++ b/spec/defines/pyvenv_spec.rb @@ -4,7 +4,10 @@ on_supported_os.each do |os, facts| context("on #{os} ") do let :facts do - facts + # python3 is required to use pyvenv + facts.merge({ + :python3_version => '3.4', + }) end let :title do '/opt/env' @@ -12,7 +15,7 @@ it { is_expected.to contain_file('/opt/env') - is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv --clear /opt/env') + is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.4 --clear /opt/env') } describe 'when ensure' do @@ -28,6 +31,6 @@ } end end - end + end #context end end