puppet-python
puppet-python copied to clipboard
pip with ensure => latest can spuriously skip the install
trafficstars
The pip resource checks whether the latest version is installed using essentially pip search pkg_name | grep -i INSTALLED.*latest. This can give false positives if you have one or more other related packages already installed, because pip search matches package names and descriptions. It doesn't seem to have an option for matching the package name exactly.
I observed this in practice when installing multiple Google API packages, for example:
$pip_packages = [
'google-cloud-core',
'google-cloud-dataflow',
'google-cloud-storage',
'google-api-python-client',
]
python::pip { $pip_packages:
ensure => latest,
virtualenv => $virtual_env_dir,
owner => $::user,
}
And google-api-python-client spuriously matched a bunch of installed packages:
Debug: Executing with ...: 'pip search google-api-python-client | grep -i INSTALLED | grep -i latest'
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless: INSTALLED: 0.0.2 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless: INSTALLED: 0.5.0 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless: INSTALLED: 0.7.5 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless: INSTALLED: 0.22.1 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless: INSTALLED: 2.6.0 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless: INSTALLED: 1.6.0 (latest)
possible fix would be to modify the grep? like this SO answer
Something like (untested):
pip search pkg_name | egrep "^.*pkg_name.*\(" | grep -i INSTALLED.*latest