Skip to content

Virtual Environment Configuration not working #700

@charlespick

Description

@charlespick

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 2023.7.0
  • Ruby: 3.0.2p107
  • Distribution: Ubuntu 22.04
  • Module version: 7.3.0

The example at /examples/pyvenv.pp does not work. It gives the error Evaluation Error: Error while evaluating a Resource Statement, Class[Python]: parameter 'pip' expects a match for Python::Package::Ensure = Enum['absent', 'installed', 'latest', 'present'], got Boolean. It appears as if this needs to be updated to be absent.

However, I still cannot get this to work properly. After changing it to absent I get errors:

Applied catalog in   2.95 seconds
--
Dependency   Exec[python_virtualenv_/opt/ansible] has failures: true
Skipping because of failed dependencies
change from 'notrun' to ['0'] failed:   'python3.10 -m venv --clear     /opt/ansible && /opt/ansible/bin/pip --log   /opt/ansible/pip.log install --upgrade pip && /opt/ansible/bin/pip   --log /opt/ansible/pip.log install --upgrade setuptools' returned 1 instead   of one of [0] (corrective)
 
Failing command:   /opt/ansible/bin/python3.10
You may need to use sudo with that   command.  After installing the   python3-venv
package, recreate your virtual   environment.
'python3.10 -m venv --clear   /opt/ansible &&   /opt/ansible/bin/pip --log /opt/ansible/pip.log install --upgrade pip   && /opt/ansible/bin/pip --log /opt/ansible/pip.log install --upgrade   setuptools' returned 1 instead of one of [0]
 
 
apt install python3.10-venv
The virtual environment was not created   successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to   install the python3-venv
package using the following command.
Applying configuration version   'puppet01-development-3a54f1279d2'
Caching catalog for   orcastra01-dev.makerland.xyz
Catalog compiled by   puppet01.makerland.xyz
Requesting catalog from   puppet01.makerland.xyz:8140 (10.4.3.18)
Loading facts
Retrieving plugin
Retrieving pluginfacts
Using environment 'development'

ChatGPT tells me this is likely because the venv module is not installed. Indeed, it is not installed. Even when I set venv => 'present' on the Python class, it doesn't seem to realize automatically it needs to install venv first because the error is the same. I've tried require => Class['python'] but it won't find the reference.

Here is the code I used:

 class { 'python':
    pip     => 'absent',
    version => 'system',
  }

  python::pyvenv { '/opt/ansible':
  }

  python::pip { 'ansible':
    ensure     => 'latest',
    virtualenv => '/opt/ansible',
  }

Not sure what to try next. Any advice appreciated.
Charles

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions