Skip to content

Can't use grains.list_present with complex(dict) types #39875

@nw0428

Description

@nw0428

Description of Issue/Question

A state like this:

service_ssh:
  grains.list_present:
    - name: services
    - value:
        - sshd:
            - hostname: localhost
            - port: 22

Will work the first time but not the second. The second time it throws the following:

        ID: service_ssh
    Function: grains.list_present
        Name: services
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/site-packages/salt/state.py", line 1734, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1651, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/states/grains.py", line 150, in list_present
                  if set(value).issubset(set(__salt__['grains.get'](name))):
              TypeError: unhashable type: 'dict'

Versions Report

Salt Version:
           Salt: 2016.3.5
 
Dependency Versions:
           cffi: 1.6.0
       cherrypy: 3.2.2
       dateutil: 2.5.3
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.5 (default, Nov  6 2016, 00:28:07)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.3.1611 Core
        machine: x86_64
        release: 3.10.0-514.6.2.el7.x86_64
         system: Linux
        version: CentOS Linux 7.3.1611 Core

Metadata

Metadata

Assignees

No one assigned

    Labels

    Corerelates to code central or existential to SaltP4Priority 4State-Modulebugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions