diff --git a/REFERENCE.md b/REFERENCE.md index 9f19f1d8..482be332 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -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', diff --git a/examples/pyvenv.pp b/examples/pyvenv.pp index b41b4306..ca2bcac7 100644 --- a/examples/pyvenv.pp +++ b/examples/pyvenv.pp @@ -1,5 +1,6 @@ class { 'python': - pip => false, + pip => 'absent', + venv => 'present', version => '3', } diff --git a/manifests/install.pp b/manifests/install.pp index 60adfc05..7c5f9ff7 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -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}", diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 7aa7202f..be73a78e 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -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', diff --git a/spec/acceptance/pyvenv_spec.rb b/spec/acceptance/pyvenv_spec.rb index 263e4a40..c6af41e4 100644 --- a/spec/acceptance/pyvenv_spec.rb +++ b/spec/acceptance/pyvenv_spec.rb @@ -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 diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index f1c2d9a1..fb68c521 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -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'