saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

pkg.installed fails on some declarations due to list out of range. #2775

Closed DaveQB closed 11 years ago

DaveQB commented 11 years ago

Some examples below. I include my declaration(s) and the error. Only some pkg.installed declarations are effected. Very weird.

Tried two different layouts here:


snmp-pkg:
  pkg:
    - installed
    - name: snmpd

snmpd:
  file.managed:
    - source: salt://soe/etc/snmp/snmpd.conf
    - name: /etc/snmp/snmpd.conf
    - mode: 640
    - require:
      - pkg: snmpd
  service:
    - running
    - require:
      - pkg: snmpd
    - watch:
      - file: /etc/snmp/snmpd.conf
  pkg:
    - installed

----------
    State: - pkg
    Name:      snmpd
    Function:  installed
        Result:    False
        Comment:   An exception occured in this state: Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/salt/state.py", line 884, in call
    *cdata['args'], **cdata['kwargs'])
  File "/usr/lib/pymodules/python2.7/salt/states/pkg.py", line 60, in installed
    cver = __salt__['pkg.version'](name)
  File "/usr/lib/pymodules/python2.7/salt/modules/apt.py", line 73, in version
    pkgs = list_pkgs(name)
  File "/usr/lib/pymodules/python2.7/salt/modules/apt.py", line 302, in list_pkgs
    ret[cols[3]] = cols[4]
IndexError: list index out of range

        Changes:   
----------

mail:
  pkg.installed:
    - names:
      - mailutils
      - ssmtp

----------
    State: - pkg
    Name:      ssmtp
    Function:  installed
        Result:    False
        Comment:   An exception occured in this state: Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/salt/state.py", line 884, in call
    *cdata['args'], **cdata['kwargs'])
  File "/usr/lib/pymodules/python2.7/salt/states/pkg.py", line 60, in installed
    cver = __salt__['pkg.version'](name)
  File "/usr/lib/pymodules/python2.7/salt/modules/apt.py", line 73, in version
    pkgs = list_pkgs(name)
  File "/usr/lib/pymodules/python2.7/salt/modules/apt.py", line 302, in list_pkgs
    ret[cols[3]] = cols[4]
IndexError: list index out of range

        Changes:   
----------

----------
    State: - pkg
    Name:      mailutils
    Function:  installed
        Result:    False
        Comment:   An exception occured in this state: Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/salt/state.py", line 884, in call
    *cdata['args'], **cdata['kwargs'])
  File "/usr/lib/pymodules/python2.7/salt/states/pkg.py", line 60, in installed
    cver = __salt__['pkg.version'](name)
  File "/usr/lib/pymodules/python2.7/salt/modules/apt.py", line 73, in version
    pkgs = list_pkgs(name)
  File "/usr/lib/pymodules/python2.7/salt/modules/apt.py", line 302, in list_pkgs
    ret[cols[3]] = cols[4]
IndexError: list index out of range

        Changes:   
----------

Running debug mode for salt-minion on the client I am getting nothing out of the ordinary besides an ERROR line that reads ok.


[INFO    ] Loading fresh modules for state activity
[INFO    ] Executing state pkg.installed for ssmtp
[INFO    ] Executing command "dpkg-query --showformat='${Status} ${Package} ${Version}\n' -W ssmtp" in directory '/root'
[DEBUG   ] stdout: install ok not-installed ssmtp
[ERROR   ] No changes made for ssmtp

[INFO    ] Loading fresh modules for state activity
[INFO    ] Executing state pkg.installed for mailutils
[INFO    ] Executing command "dpkg-query --showformat='${Status} ${Package} ${Version}\n' -W mailutils" in directory '/root'
[DEBUG   ] stdout: install ok not-installed mailutils
[ERROR   ] No changes made for mailutils

[INFO    ] Executing state pkg.installed for snmpd
[INFO    ] Executing command "dpkg-query --showformat='${Status} ${Package} ${Version}\n' -W snmpd" in directory '/root'
[DEBUG   ] stdout: install ok not-installed snmpd
[ERROR   ] No changes made for snmpd
thatch45 commented 11 years ago

Thanks for the heads up, on the list for 0.10.6

DaveQB commented 11 years ago

No worries.

So there is a known solution for this?

thatch45 commented 11 years ago

not that I know of, I will try to get to this ASAP

DaveQB commented 11 years ago

It looks, on the surface, to be pretty straight forward for someone with their head in the code. But I could be wrong.

Thanks Thomas.

UtahDave commented 11 years ago

what OS are you on? I just installed snmpd using the related part of your state above.

DaveQB commented 11 years ago

Hmmm odd.

Distributor ID: Ubuntu Description: Ubuntu 12.04.1 LTS Release: 12.04 Codename: precise

On AWS EC2.

What is the python way to get more verbose info, like -x in bash? Maybe I can present more information as to what it is doing.

UtahDave commented 11 years ago

I've tested each of the states listed above and they all worked correctly. I believe all the updates to the package state have fixed this problem in the latest git.

Is anyone seeing this problem in the latest git?

DaveQB commented 11 years ago

Cool. Thanks @UtahDave So this will be fixed in 10.6?

UtahDave commented 11 years ago

Yes, it's already fixed in the latest git. 0.10.6 should be out later this week with these fixes include.