Required package not found yet package is installed.

1,197 views
Skip to first unread message

skirkpatrick

unread,
Mar 13, 2014, 7:11:36 PM3/13/14
to salt-...@googlegroups.com

I have the following state:

# Install pip 'gitpython' so Salt can use Git fileserver (gitfs) backend
gitpython:
  pip.installed:
    - require:
      - pkg: python-pip

When I run state.highstate I see this:

[root@mymaster ~]# salt 'mymaster' state.highstate Test=True
mymaster:
----------
          ID: gitpython
    Function: pip.installed
      Result: False
     Comment: The following requisites were not found:
                                 require:
                                     pkg: python-pip

Yet the package is installed:

[root@mymaster ~]# yum info python-pip
Installed Packages
Name        : python-pip
Arch        : noarch
Version     : 1.3.1
Release     : 4.el6
Size        : 1.0 M
Repo        : installed
From repo   : epel
Summary     : A tool for installing and managing Python packages
License     : MIT
Description : Pip is a replacement for `easy_install
            : <http://peak.telecommunity.com/DevCenter/EasyInstall>`_.  It uses mostly the
            : same techniques for finding packages, so packages that were made
            : easy_installable should be pip-installable as well.

Running this on on a CentOS 6.5 host which is both master and minion.

Version info:
[root@mymaster ~]# salt --versions-report
           Salt: 2014.1.0
         Python: 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
         Jinja2: 2.2.1
       M2Crypto: 0.20.2
 msgpack-python: 0.1.13
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
         PyYAML: 3.10
          PyZMQ: 2.2.0.1
            ZMQ: 3.2.4

Troubleshooting pointers?  I have looked in the minion logs but nothing jumps out as an error.  Could this be a typo on my part or a known bug that has already been addressed?

Steve Kirkpatrick

unread,
Mar 13, 2014, 8:57:00 PM3/13/14
to salt-...@googlegroups.com
Hello again,

Trying to figure this out, I managed to change the symptom.  Hoping someone understands the new error message below.

I noticed that the pip install was happening before the python-pip package install so I did some reading up on Ordering States.
That lead me to change gitpython.sls as follows:

[root@mymaster salt]# cat gitpython.sls
include:
  - core-linux

# Install pip 'gitpython' so Salt can use Git fileserver (gitfs) backend
gitpython:
  pip.installed:
    - require:
      - sls: core-linux

and core-linux.sls looks like this:

[root@mymaster salt]# cat core-linux.sls
# Install these core packages on ALL Linux hosts
corepkgs:
  pkg.installed:
    - pkgs:
      - man                                            # Man pages
      - {{ salt['pillar.get']('pkgs:vim', 'vim') }}    # Correct version of vim editor
      - pyOpenSSL                                      # Python library for OpenSSL
      - git                                            # Git SCM tools
      - python-pip                                     # pip command to manage python libraries

Now, when I do a state.show_highstate, it shows the correct order (i.e. python-pip get installed before the pip.install).
Unfortunately, it also shows a new/different error:

local:
----------
          ID: corepkgs
    Function: pkg.installed
      Result: None
     Comment: The following packages are set to be installed/updated: pyOpenSSL, ncdu, tree, jq, python-pip, man, vim-enhanced.
     Changes:
----------
--- other stuff removed
----------
          ID: gitpython
    Function: pip.installed
      Result: False
     Comment: State pip.installed found in sls gitpython is unavailable
     Changes:

Does this error ring any bells?  

Just for grins, I rebuilt my master using v2014.1.0rc3 and v0.17.5 and the problem stays the same so my guess is I am doing something wrong in my state file or ??

Thanks for any pointers.

Steve.

Dmitry Malinovsky

unread,
Mar 14, 2014, 4:54:44 AM3/14/14
to salt-...@googlegroups.com
I have the following state:

# Install pip 'gitpython' so Salt can use Git fileserver (gitfs) backend
gitpython:
  pip.installed:
    - require:
      - pkg: python-pip

When I run state.highstate I see this:

[root@mymaster ~]# salt 'mymaster' state.highstate Test=True
mymaster:
----------
          ID: gitpython
    Function: pip.installed
      Result: False
     Comment: The following requisites were not found:
                                 require:
                                     pkg: python-pip
 
This is because python-pip should be an identifier for another state, for example,
python-pip:
    pkg.installed

Ethan Erchinger

unread,
Mar 14, 2014, 11:20:47 AM3/14/14
to salt-...@googlegroups.com


On Friday, March 14, 2014 1:54:44 AM UTC-7, Dmitry Malinovsky wrote:
 
This is because python-pip should be an identifier for another state, for example,
python-pip:
    pkg.installed

He's got that covered under the corepkgs requisite.

Steve, I personally think there is a core with yum or pkg requisites problem in 2014.1.0, and I don't know if it's been fixed.  You mentioned downgrading the master, but all of this processing is done on the client.  I would try moving you client to 0.17.5 and see if it's still an issue (I highly suspect it won't be an issue).

Ethan

David Anderson

unread,
Mar 14, 2014, 12:32:29 PM3/14/14
to salt-...@googlegroups.com
"State pip.installed found in sls gitpython is unavailable"

This means that the state module 'pip' is not being loaded by the salt
minion. The pip module does some checks before it is loaded into salt (
https://github.com/saltstack/salt/blob/develop/salt/states/pip_state.py#L31
):

# Import 3rd-party libs
try:
import pip
import pip.req
HAS_PIP = True
except ImportError:
HAS_PIP = False


Jinja state templates are all compiled by the minion at the beginning of
a state run. Because you do not have pip installed when the states are
compiled, the minion cannot load the pip state module. It's a
chicken/egg problem and I bet if you run the core-linux sls first, then
run the highstate, it will work.

If you want to install python-pip and use the pip state module in the
same run, you can use the pydsl renderer with the ability to execute a
state at render time:
http://docs.saltstack.com/ref/renderers/all/salt.renderers.pydsl.html#render-time-state-execution
Be sure to run
http://docs.saltstack.com/ref/modules/all/salt.modules.saltutil.html#salt.modules.saltutil.refresh_modules
(via the __salt__ dunder) after you have installed python-pip.

This method also works for things like installing mako and rendering
mako templates in the same state run, etc.
--
Dave
> --
> You received this message because you are subscribed to the Google
> Groups "Salt-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to salt-users+...@googlegroups.com
> <mailto:salt-users+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Michael Barrientos

unread,
Mar 14, 2014, 12:37:18 PM3/14/14
to salt-...@googlegroups.com
Using pydsl just to run pip within the same run it is installed is overkill. Just add a "reload_modules: true" to the state which installs python-pip.

David Anderson

unread,
Mar 14, 2014, 12:41:57 PM3/14/14
to salt-...@googlegroups.com
That is indeed much easier :)
--
Dave
> > an email to salt-users+...@googlegroups.com <javascript:>
> > <mailto:salt-users+...@googlegroups.com <javascript:>>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Salt-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to salt-users+...@googlegroups.com
> <mailto:salt-users+...@googlegroups.com>.
Message has been deleted

Steve Kirkpatrick

unread,
Mar 14, 2014, 2:05:22 PM3/14/14
to salt-...@googlegroups.com
I think I am my own worst enemy sometimes.

Thanks Dave and Michael for the suggestions.

Michael, after reading the docs that you linked to, I went ahead and added "reload_modules: true” to the corepkgs state which installs python-pip.

I then ran "salt 'mymaster' state.highstate Test=True “ and got the same error.  Hmmm

OK, let’s try it without the Test=True.  Now it works.  Hmmm… I see how that makes sense.

According to the docs, salt is pretty smart about reloading modules at the appropriate time.  Did I even need the reload_modules: true”?  Maybe the “include” I added to gitpython.sls to fix the original issue was all I needed.  My mistake was keeping the “Test=True” on my state.highstate.

To test this theory, I rebuilt my salt master/minion host and tried "salt 'mymaster’ state.highstate” after commenting out the “reload_modules: true” line.
Works fine.

Note to self: “Test=True” is useful up to a point.  Sometimes you actually have to let salt do its thing for real to get the desired result. :-}

Thanks to all for the pointers.  Appreciate it.

Now on to the next issue.

Steve.


To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages