Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nw0428 opened this issue Mar 7, 2017 · 6 comments
Closed

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

nw0428 opened this issue Mar 7, 2017 · 6 comments
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt P4 Priority 4 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around State-Module
Milestone

Comments

@nw0428
Copy link

nw0428 commented Mar 7, 2017

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
@Ch3LL
Copy link
Contributor

Ch3LL commented Mar 8, 2017

Looks like i'm able to replicate this.

Here is a docker container for anyone that wants to quickly replicate this:

  1. docker run -it -v /home/ch3ll/git/salt/:/testing/ ch3ll/issues:39875 salt-call --local state.sls test -ldebug ( where /home/ch3ll/git/salt is a local cloned git repo of salt.)

Looks like we need to get this fixed thanks

@Ch3LL Ch3LL added Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P4 Priority 4 State-Module labels Mar 8, 2017
@Ch3LL Ch3LL added this to the Approved milestone Mar 8, 2017
@stale
Copy link

stale bot commented Sep 14, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Sep 14, 2018
@stale stale bot closed this as completed Sep 21, 2018
@mickenordin
Copy link
Contributor

This seems to be an issue still, I am affected:
In the state:

grains.list_present:

  • name: ip_whitelist
  • value:
    • source: "0.0.0.0/0"
      port: 1234
    • source: "0.0.0.0/0"
      port: 5678

From the log:

2019-04-26T14:35:13.895806+02:00 example-lab-srv01.example.se salt-minion[577]: [ERROR ] An exception occurred in this state: Traceback (most recent call last):
2019-04-26T14:35:13.896144+02:00 example-lab-srv01.example.se salt-minion[577]: File "/usr/lib/python3/dist-packages/salt/state.py", line 1933, in call
2019-04-26T14:35:13.896346+02:00 example-lab-srv01.example.se salt-minion[577]: **cdata['kwargs'])
2019-04-26T14:35:13.896539+02:00example-lab-srv01.example.se salt-minion[577]: File "/usr/lib/python3/dist-packages/salt/loader.py", line 1939, in wrapper
2019-04-26T14:35:13.896731+02:00 example-lab-srv01.example.sesalt-minion[577]: return f(*args, **kwargs)
2019-04-26T14:35:13.896921+02:00 example-lab-srv01.example.se salt-minion[577]: File "/usr/lib/python3/dist-packages/salt/states/grains.py", line 177, in list_present
2019-04-26T14:35:13.897120+02:00 example-lab-srv01.example.se salt-minion[577]: if set(value).issubset(set(salt'grains.get')):
2019-04-26T14:35:13.897302+02:00 example-lab-srv01.example.se salt-minion[577]: TypeError: unhashable type: 'dict'

@dwoz dwoz reopened this May 5, 2019
@stale
Copy link

stale bot commented May 5, 2019

Thank you for updating this issue. It is no longer marked as stale.

@stale stale bot removed the stale label May 5, 2019
@mickenordin
Copy link
Contributor

mickenordin commented May 9, 2019

@dwoz I have submitted a PR that I think fixes this, and that has been reviewed. Do you have any idea of if and when that PR will be merged?

Edit: The PR has been mered now, so this bug should be fixed 🎉

@Ch3LL
Copy link
Contributor

Ch3LL commented May 10, 2019

Thanks @mickenordin :) I'll go ahead and close

@Ch3LL Ch3LL closed this as completed May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt P4 Priority 4 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around State-Module
Projects
None yet
Development

No branches or pull requests

4 participants