Skip to content

state.sls fails to render state with pillar data: Jinja variable 'dict object' has no attribute #29028

Closed

Description

@kevins9

This is only occurring on my minions running Salt 2015.5.5 and CentOS 7. Issue is similar to #16727 and #16656.

Version info - master and minion
[root@master ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@master ~]# salt --versions
           Salt: 2015.5.3
         Python: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
         Jinja2: 2.7.3
       M2Crypto: 0.20.2
 msgpack-python: 0.1.13
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 2.2.0.1
           RAET: Not Installed
            ZMQ: 3.2.4
           Mako: Not Installed
        Tornado: 2.2.1

[root@centos7test-01 ~]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
[root@centos7test-01 ~]# salt-call --versions
           Salt: 2015.5.5
         Python: 2.7.5 (default, Jun 24 2015, 00:41:19)
         Jinja2: 2.7.2
       M2Crypto: 0.21.1
 msgpack-python: 0.4.6
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.3.1
           RAET: Not Installed
            ZMQ: 3.2.5
           Mako: 0.8.1
        Tornado: Not Installed
        timelib: Not Installed
       dateutil: 1.5
Pillar top.sls
base:
  'role:bugdemo':
    - match: grain
    - bugdemo
Pillar bugdemo.sls
bugdemo: problem
minion /etc/salt/grains
role: bugdemo
Master /srv/salt/dev/bugdemo.sls
/var/tmp/{{ pillar['bugdemo'] }}:
  file.exists:
    - name: /var/tmp/{{ pillar['bugdemo'] }}

(Note: master config has "dev" saltenv configured with root /srv/salt/dev)

Evidence

Pillar value is present:

[root@centos7test-01 ~]# salt-call pillar.get bugdemo
local:
    problem

State fails to render when calling state.sls:

[root@centos7test-01 ~]# salt-call state.sls bugdemo saltenv=dev test=True
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file from saltenv 'dev', ** skipped ** latest already in cache 'salt://bugdemo.sls'
[CRITICAL] Rendering SLS 'dev:bugdemo' failed: Jinja variable 'dict object' has no attribute 'bugdemo'
local:
    Data failed to compile:
----------
    Rendering SLS 'dev:bugdemo' failed: Jinja variable 'dict object' has no attribute 'bugdemo'

Yet oddly enough, state.show_sls works:

[root@centos7test-01 ~]# salt-call state.show_sls bugdemo saltenv=dev
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file from saltenv 'dev', ** skipped ** latest already in cache 'salt://bugdemo.sls'
local:
    ----------
    /var/tmp/problem:
        ----------
        __env__:
            dev
        __sls__:
            bugdemo
        file:
            |_
              ----------
              name:
                  /var/tmp/problem
            - exists
            |_
              ----------
              order:
                  10000

This works on another minion:

[root@centos6test-01 ~]# salt-call grains.get role
local:
    bugdemo
[root@centos6test-01 ~]# salt-call pillar.get bugdemo
local:
    problem
[root@centos6test-01 ~]# salt-call state.sls bugdemo saltenv=dev test=True
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file from saltenv 'dev', ** skipped ** latest already in cache 'salt://bugdemo.sls'
[INFO    ] Running state [/var/tmp/problem] at time 17:25:33.280407
[INFO    ] Executing state file.exists for /var/tmp/problem
[ERROR   ] Specified path /var/tmp/problem does not exist
[INFO    ] Completed state [/var/tmp/problem] at time 17:25:33.281307
local:
----------
          ID: /var/tmp/problem
    Function: file.exists
      Result: False
     Comment: Specified path /var/tmp/problem does not exist
     Started: 17:25:33.280407
    Duration: 0.9 ms
     Changes:

Summary
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1

[root@centos6test-01 ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[root@centos6test-01 ~]# salt-call --versions
           Salt: 2015.5.3
         Python: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
         Jinja2: 2.2.1
       M2Crypto: 0.20.2
 msgpack-python: 0.4.6
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.3.1
           RAET: Not Installed
            ZMQ: 3.2.5
           Mako: Not Installed
        Tornado: Not Installed

Activity

  1. kevins9 commented on Nov 19, 2015

    @kevins9
    Author

    When rewriting the state to use salt['pillar.get']('bugdemo') references, as per recommended in documentation, things work differently:

    bugdemo.sls
    /var/tmp/{{ salt['pillar.get']('bugdemo') }}:
      file.exists:
        - name: /var/tmp/{{ salt['pillar.get']('bugdemo') }}
    
    Works correctly on the good minion
    [root@centos6test-01 ~]# salt-call pillar.get bugdemo
    local:
        problem
    [root@centos6test-01 ~]# salt-call state.sls bugdemo saltenv=dev test=True
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'dev', ** skipped ** latest already in cache 'salt://bugdemo.sls'
    [INFO    ] Running state [/var/tmp/problem] at time 17:55:50.406954
    [INFO    ] Executing state file.exists for /var/tmp/problem
    [ERROR   ] Specified path /var/tmp/problem does not exist
    [INFO    ] Completed state [/var/tmp/problem] at time 17:55:50.407932
    local:
    ----------
              ID: /var/tmp/problem
        Function: file.exists
          Result: False
         Comment: Specified path /var/tmp/problem does not exist
         Started: 17:55:50.406954
        Duration: 0.978 ms
         Changes:
    
    Summary
    ------------
    Succeeded: 0
    Failed:    1
    ------------
    Total states run:     1
    
    Works incorrectly on the bad minion
    [root@centos7test-01 ~]# salt-call pillar.get bugdemo
    local:
        problem
    [root@centos7test-01 ~]# salt-call state.sls bugdemo saltenv=dev test=True
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'dev', ** skipped ** latest already in cache 'salt://bugdemo.sls'
    [INFO    ] Running state [/var/tmp/] at time 17:53:38.463031
    [INFO    ] Executing state file.exists for /var/tmp/
    [INFO    ] Path /var/tmp/ exists
    [INFO    ] Completed state [/var/tmp/] at time 17:53:38.463903
    local:
    ----------
              ID: /var/tmp/
        Function: file.exists
          Result: True
         Comment: Path /var/tmp/ exists
         Started: 17:53:38.463031
        Duration: 0.872 ms
         Changes:
    
    Summary
    ------------
    Succeeded: 1
    Failed:    0
    ------------
    Total states run:     1
    

    It never filled in the value "problem" into the state.

  2. added
    bug
    severity-medium
    Core
    P3
    on Nov 19, 2015
  3. added this to the Approved milestone on Nov 19, 2015
  4. jfindlay commented on Nov 19, 2015

    @jfindlay
    Contributor

    @kevins9, thanks for the report. Is it possible for you to reproduce this on 2015.8.1?

  5. kevins9 commented on Nov 19, 2015

    @kevins9
    Author

    I updated the minion to 2015.8.1, and the problem persists - the pillar value is undefined when running state.sls:

    [root@centos7test-01 ~]# salt-call saltutil.sync_grains
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'base', ** skipped ** latest already in cache u'salt://top.sls'
    [ERROR   ] Template was specified incorrectly: False
    [ERROR   ] Template was specified incorrectly: False
    [INFO    ] Creating module dir '/var/cache/salt/minion/extmods/grains'
    [INFO    ] Syncing grains for environment 'dev'
    [INFO    ] Loading cache from salt://_grains, for dev)
    [INFO    ] Caching directory u'_grains/' for environment 'dev'
    local:
    
    [root@centos7test-01 ~]# salt-call saltutil.refresh_pillar
    local:
        True
    
    [root@centos7test-01 ~]# salt-call state.clear_cache
    local:
        - highstate.cache.p
    
    [root@centos7test-01 ~]# salt-call state.sls bugdemo saltenv=dev test=True
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'dev', ** skipped ** latest already in cache u'salt://bugdemo.sls'
    [INFO    ] Running state [/var/tmp/] at time 12:57:08.802585
    [INFO    ] Executing state file.exists for /var/tmp/
    [INFO    ] Path /var/tmp/ exists
    [INFO    ] Completed state [/var/tmp/] at time 12:57:08.803485
    local:
    ----------
              ID: /var/tmp/
        Function: file.exists
          Result: True
         Comment: Path /var/tmp/ exists
         Started: 12:57:08.802585
        Duration: 0.9 ms
         Changes:
    
    Summary for local
    ------------
    Succeeded: 1
    Failed:    0
    ------------
    Total states run:     1
    Total run time:   0.900 ms
    
    [root@centos7test-01 ~]# salt-call pillar.get bugdemo
    local:
        problem
    
    [root@centos7test-01 ~]# salt-call state.show_sls bugdemo saltenv=dev
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'dev', ** skipped ** latest already in cache u'salt://bugdemo.sls'
    local:
        ----------
        /var/tmp/problem:
            ----------
            __env__:
                dev
            __sls__:
                bugdemo
            file:
                |_
                  ----------
                  name:
                      /var/tmp/problem
                - exists
                |_
                  ----------
                  order:
                      10000
    
    [root@centos7test-01 ~]# salt-call --versions
    Salt Version:
               Salt: 2015.8.1
    
    Dependency Versions:
             Jinja2: 2.7.2
           M2Crypto: 0.21.1
               Mako: 0.8.1
             PyYAML: 3.10
              PyZMQ: 14.3.1
             Python: 2.7.5 (default, Jun 24 2015, 00:41:19)
               RAET: Not Installed
            Tornado: 4.2.1
                ZMQ: 3.2.5
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: 1.5
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
            libnacl: Not Installed
       msgpack-pure: Not Installed
     msgpack-python: 0.4.6
       mysql-python: 1.2.3
          pycparser: Not Installed
           pycrypto: 2.6.1
             pygit2: Not Installed
       python-gnupg: Not Installed
              smmap: Not Installed
            timelib: Not Installed
    
    System Versions:
               dist: centos 7.1.1503 Core
            machine: x86_64
            release: 3.10.0-229.11.1.el7.x86_64
             system: CentOS Linux 7.1.1503 Core
    
    

    The master is still running the same version as prior. I may be able to update that later today and test again.

  6. jfindlay commented on Nov 19, 2015

    @jfindlay
    Contributor

    Thanks for the extra info, @kevins9.

  7. joberget commented on Nov 26, 2015

    @joberget

    Any news on this issue? I am seeing the same problems here on 2015.8.1 on Ubuntu 14.04 LTS.

  8. jfindlay commented on Dec 1, 2015

    @jfindlay
    Contributor

    @joberget, not that I know of.

  9. dennsi commented on Dec 4, 2015

    @dennsi

    I can confirm this issue on Debian 8.2 with the minion version 2015.8.3 and 2015.5.8 booth from http://repo.saltstack.com/apt/debian/8. It works with the Ubuntu packages 2015.5.3 on my debian system from:
    http://ppa.launchpad.net/saltstack/salt/ubuntu

    salt-minion --versions-report
                      Salt: 2015.5.3
                    Python: 2.7.9 (default, Mar  1 2015, 12:57:24)
                    Jinja2: 2.7.3
                  M2Crypto: 0.21.1
            msgpack-python: 0.4.2
              msgpack-pure: Not Installed
                  pycrypto: 2.6.1
                   libnacl: Not Installed
                    PyYAML: 3.11
                     ioflo: Not Installed
                     PyZMQ: 14.4.0
                      RAET: Not Installed
                       ZMQ: 4.0.5
                      Mako: 1.0.0
                   Tornado: Not Installed
     Debian source package: 2015.5.3+ds-1trusty1
    
  10. thegrmpf commented on Dec 4, 2015

    @thegrmpf

    same issue here with minion 2015.5.5 running on opensuse 13.2

  11. added
    P1
    on Dec 4, 2015
  12. 26 remaining items

  13. added
    Silicon v3004.0
    and removed
    Aluminium
    on Mar 24, 2021
  14. modified the milestones: Aluminium, Silicon on Mar 24, 2021
  15. sagetherage commented on May 12, 2021

    @sagetherage
    Contributor

    I also get error . salt-master version :- salt-master 2016.11.3 (Carbon) and salt-master version :- salt-master 2016.11.3 (Carbon)

    Data failed to compile:

    Rendering SLS 'base:ldap' failed: Jinja variable 'dict object' has no attribute 'roles'
    

    @vikrant-agarwal Salt v2016.11.3 is no longer supported and breaking changes are likely.

  16. modified the milestones: Silicon, Approved on Aug 12, 2021
  17. dwoz commented on Aug 16, 2021

    @dwoz
    Contributor

    I'm convinced this issue has been fixed by #58369. I am closing the issue for now, if anyone is able to re-produce this in a version >3002 please comment and we'll re-open the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CorePillarSilicon v3004.0bugseverity-high

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions