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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#!/bin/sh
# 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"
    else
        echo "$ver"
    fi
else
    exec /usr/bin/pip "$@"
fi

pip puppet