0%

State pip.installed found in sls xxx is unavailable

I’ve been upgrading my Salt cluster which was created a few months ago and left as it was. The problem is happened after sudo do-release-upgrade from Ubuntu 12.04 to 14.04 with salt-master and salt-minions. When I run sudo salt '*' state.highstate, it failed because pip.installed state is unavailable, although pip is installed successfully. After googled I found some related posts.

It’s happened before

As I wrote in this post it’s happened before. At that time I manually removed python-pip packege then re-installed via get-pip.py as a workaround.

$ sudo apt-get remove python-pip
$ wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
$ sudo python get-pip.py

This SLS didn’t work

This SLS file occurs a error. It looks correct at first sight.

/srv/salt/docker/init.sls
...
python-pip:
pkg.installed

docker-py:
pip.installed:
- require:
- pkg: pkg-core
- pkg: python-pip

A revised SLS

In found a related Salt Documatation in 22.26.22.2. Reloading Modules. It tells me how to solve this problem using reload_modules flag.

pep8.sls
python-pip:
cmd:
- run
- cwd: /
- name: easy_install --script-dir=/usr/bin -U pip
- reload_modules: true

pep8:
pip.installed
requires:
- cmd: python-pip

I revised my SLS as below.

/srv/salt/docker/init.sls
python-pip:
cmd:
- run
- cwd : /
- name: easy_install --script-dir=/usr/bin -U pip
- reload_modules: true

docker-py:
pip.installed:
- require:
- pkg: pkg-core
- cmd: python-pip

After purged old package, it works this time.

$ sudo salt '*' pkg.purge python-pip
$ sudo salt '*' pkg.refresh_db
$ sudo salt '*' state.highstate