voxpupuli / puppet-python

Puppet module for installing and managing Python, pip, virtualenvs and Gunicorn virtual hosts.
https://forge.puppetlabs.com/puppet/python
Apache License 2.0
199 stars 375 forks source link

Duplicate declaration for python$version-venv #517

Closed baurmatt closed 4 years ago

baurmatt commented 4 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

$python_version = '3.6'
class { 'python':
  version => "python${python_version}",
}

python::pyvenv { '/opt/test1':
  version => $python_version,
}
python::pyvenv { '/opt/test2':
  version => $python_version,
}

What are you seeing

root@015a1178cad3:/# puppet apply --test --noop test.pp
Info: Loading facts
Info: Loading facts
Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Duplicate declaration: Package[python3.6-venv] is already declared at (file: /etc/puppetlabs/code/environments/production/modules/python/manifests/pyvenv.pp, line: 53); cannot redeclare (file: /etc/puppetlabs/code/environments/production/modules/python/manifests/pyvenv.pp, line: 53) (file: /etc/puppetlabs/code/environments/production/modules/python/manifests/pyvenv.pp, line: 53, column: 11) (file: /test.pp, line: 9) on node 015a1178cad3

What behaviour did you expect instead

Creates two pyvenvs.

Output log

Any additional information you'd like to impart

baurmatt commented 4 years ago

Will provide a PR

baurmatt commented 4 years ago

Also reproducible with this code:

$python3_venv_package = 'python3.6-venv'

ensure_packages ($python3_venv_package, {
  before => File['/opt/test2'],
})
file { '/opt/test2':
  ensure => directory,
}

ensure_packages ($python3_venv_package, {
  before => File['/opt/test1'],
})
file { '/opt/test1':
  ensure => directory,
}

Could be introduced by https://github.com/puppetlabs/puppetlabs-stdlib/commit/9cdbbcc238ac4464a2349bd6186957e722afb1fe#diff-371173ef002424744f2dbf1a0afdfcd6