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 370 forks source link

Pip uninstall does not support pkgname variable #606

Closed brabiega closed 3 years ago

brabiega commented 3 years ago

Affected Puppet, Ruby, OS and module versions/distributions

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

        python::pip { '/opt/virtualenv/oco3/wheel':
            ensure     => 'absent',
            pkgname    => 'wheel',
            virtualenv => '/opt/virtualenv/oco3'
        }

What are you seeing

Puppet error on executing pip uninstall

What behaviour did you expect instead

Uninstalled package determined by $pkgname within given $virtualenv

Output log

Relevant part of the output

Python::Pip[/opt/virtualenv/oco3/wheel]/Exec[pip_uninstall_/opt/virtualenv/oco3/wheel]/returns: ERROR: Invalid requirement: '/opt/virtualenv/oco3/wheel'
Python::Pip[/opt/virtualenv/oco3/wheel]/Exec[pip_uninstall_/opt/virtualenv/oco3/wheel]/returns: Hint: It looks like a path. File '/opt/virtualenv/oco3/wheel' does not exist.
Error: 'echo y | /opt/virtualenv/oco3/bin/pip uninstall   /opt/virtualenv/oco3/wheel' returned 1 instead of one of [0]
Error: Python::Pip[/opt/virtualenv/oco3/wheel]/Exec[pip_uninstall_/opt/virtualenv/oco3/wheel]/returns: change from 'notrun' to ['0'] failed: 'echo y | /opt/virtualenv/oco3/bin/pip uninstall   /opt/virtualenv/oco3/wheel' returned 1 instead of one of [0]

Any additional information you'd like to impart

BUG location https://github.com/voxpupuli/puppet-python/blob/master/manifests/pip.pp#L223

      default: {
        # Anti-action, uninstall.
        $command        = "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}"
        $unless_command = "! ${pip_env} list | grep -i -e '${grep_regex}'"
      }

As you can see this piece of code doesn't respect $pkgname from define params. Instead it uses $name to build the command