puppet / pip_version / facter

puppet / pip_version / facter

  • Written by
    Walter Doekes
  • Published on

Every once in a while I have to deal with machines provisioned by puppet.

I can’t seem to get used to the fact that --test not only tests, but actually does. It displays what it does though output, which is nice. To test without applying, you need the --noop flag.

But, today I wanted to bring up the quick fix to this old warning/error:

Error: Facter: error while resolving custom fact "pip_version":
  undefined method `[]' for nil:NilClass

The cause of the issue is an old version of pip(1) which has no --version parameter. Here’s a quick fix you can place in /usr/local/bin/pip:

# Wrapper that provides --version to older pip versions.
# Used by the Puppet pip_version.rb module which expects --version.
if test "$*" = "--version"; then
    ver=$(/usr/bin/pip --version 2>/dev/null)
    if test $? != 0; then
        ver=$(dpkg -l python-pip | awk '/^ii/{print $3}')
        echo "pip $ver from dpkg"
        echo "$ver"
    exec /usr/bin/pip "$@"

Back to overview Newer post: letsencrypt / expiry mails / unsubscribe Older post: ubuntu zesty / apt / dns timeout / srv records