Salt: Function: pkg.installed. Yum does not update installed package

Created on 7 Jun 2017  路  4Comments  路  Source: saltstack/salt

My code is:

others:
  pkg.installed:
    - sources:
      - epel-release: https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm
      - salt-latest: https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm

and I'm getting error:

errors:
    - Loaded plugins: fastestmirror, replace
      Setting up Install Process
      Examining     /var/cache/salt/minion/extrn_files/base/repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm: salt-repo-latest-2.el6.noarch
      /var/cache/salt/minion/extrn_files/base/repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm: does not update installed package.
      Error: Nothing to do

I thinkt that may be a problem with salt-repo-latest-2.el6.noarch.rpm. When I manually run yum install for this RPM's I'm getting the same error but running in Salt Stack only getting this error.

It should end with:

      ID: others
Function: pkg.installed
  Result: True
 Comment: All specified packages are already installed
 Started: 10:45:33.171971
Duration: 595.672 ms
 Changes: 

but I'm getting:

     ID: others
Function: pkg.installed
  Result: False
 Comment: Error occurred installing package(s). Additional info follows:

          errors:
              - Loaded plugins: fastestmirror, replace
                Setting up Install Process
                Examining /var/cache/salt/minion/extrn_files/base/repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm: salt-repo-latest-2.el6.noarch
                /var/cache/salt/minion/extrn_files/base/repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm: does not update installed package.
                Error: Nothing to do
 Started: 10:46:13.906581
Duration: 8988.515 ms
 Changes:  

Running yum clean all not helping.

Versions Report

Salt Version:
           Salt: 2016.11.5

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.4.1
      docker-py: 1.7.0
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.20.2
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: 1.2.3c1
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: 3.4.3
         pygit2: Not Installed
         Python: 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.5.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: centos 6.9 Final
        machine: x86_64
        release: 2.6.32-696.3.1.el6.x86_64
         system: Linux
        version: CentOS 6.9 Final

Posted also on stackoverflow.com

Question

Most helpful comment

Oh, that is my bad.

Also, the package name is salt-repo not salt-latest

It looks like rpm thinks it is salt-repo-latest

But we use yum list installed to check which packages are installed, so the state you actually want is.

others:
  pkg.installed:
    - sources:
      - epel-release: https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm
      - salt-repo: https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm

All 4 comments

I believe what you want is pkg.latest. You should just be able to change pkg.installed to pkg.latest and it should work.

Thanks,
Daniel

No it won't work:

ID: others
    Function: pkg.latest
      Result: False
     Comment: The "sources" parameter is not supported.
     Started: 19:49:32.439086
    Duration: 0.652 ms
     Changes:

And... why pkg.installed is working for epel rpm but not for salt-latest?

Oh, that is my bad.

Also, the package name is salt-repo not salt-latest

It looks like rpm thinks it is salt-repo-latest

But we use yum list installed to check which packages are installed, so the state you actually want is.

others:
  pkg.installed:
    - sources:
      - epel-release: https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm
      - salt-repo: https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm

Great! Start working!

Was this page helpful?
0 / 5 - 0 ratings