Fix bootstrapping python::pyvenv when Python is not installed#716
Fix bootstrapping python::pyvenv when Python is not installed#716
python::pyvenv when Python is not installed#716Conversation
This module that manage python needs python to be installed in order to
work properly under certain conditions.
When python is not installed on a node, the python_version fact does not
have a value. When using `python::pyvenv` on such a system without a
specific version set, a call of the split() function on this unde value
cause an error te be raised:
```
Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, The function 'split' was called with arguments it does not accept. It expects one of:
(String str, String pattern)
rejected: parameter 'str' expects a String value, got Undef
(String str, Regexp pattern)
rejected: parameter 'str' expects a String value, got Undef
(String str, Type[Regexp] pattern)
rejected: parameter 'str' expects a String value, got Undef
(Sensitive[String] sensitive, String pattern)
rejected: parameter 'sensitive' expects a Sensitive[String] value, got Undef
(Sensitive[String] sensitive, Regexp pattern)
rejected: parameter 'sensitive' expects a Sensitive[String] value, got Undef
(Sensitive[String] sensitive, Type[Regexp] pattern)
rejected: parameter 'sensitive' expects a Sensitive[String] value, got Undef (file: /etc/puppetlabs/code/environments/production/modules/python/manifests/pyvenv.pp, line: 48, column: 34) (file: /etc/puppetlabs/code/environments/production/modules/taiga/manifests/back/install.pp, line: 15) on node debian12-64-puppet7.example.com
```
e117ac1 to
81daea2
Compare
When Python is not installed, the python_version fact is undef, but we need to know which version of Python is going to be installed by the module in order to use the proper command invocation for building virtual envs. This issue only occurs when the user use the system version of Python, so add the default version of Python for supported operating systems into Hiera and use that as a fallback when the version of Python is unknown.
| @@ -0,0 +1 @@ | |||
| python::default_system_version: "3.11" | |||
There was a problem hiding this comment.
For the common file, the choice of 3.11 was arbitrary. We really only want a default for systems missing in Hiera data (e.g. operating systems not listed as supported). For example the test suite mocks Debian 6, and we do not want to add support for this in Hiera 🙃
python::pyvenv when Python is not installed
|
This fix the issue I am facing: https://github.com/opus-codium/puppet-taiga/actions/runs/14652911906?pr=78 Ready for review! |
kenyon
left a comment
There was a problem hiding this comment.
Nice, this reminds me of what I was talking about in voxpupuli/puppet-puppetboard#403. We have essentially duplicated your system-version work here in the puppetboard hiera data: https://github.com/voxpupuli/puppet-puppetboard/tree/88d2e9a038ae9da14344d422397f6708df2ba9b4/data/os
Interesting.
|
|
Yes, seems like modules using python, like puppet-puppetboard, should be able to depend on the default system Python version provided by puppet-python. Not sure about the RHEL 8 Python 3 version. |
|
Fine, let's merge this, make a new release and allow to simplify consumer ports! |
When python is not installed, a catalog with a
python::pyvenvresource should compile and apply successfully.Instead it currently cause a catalog compilation error: