{"action":"opened","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/36796","repository_url":"https://api.github.com/repos/saltstack/salt","labels_url":"https://api.github.com/repos/saltstack/salt/issues/36796/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/36796/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/36796/events","html_url":"https://github.com/saltstack/salt/issues/36796","id":181172597,"number":36796,"title":"Problem with salt-ssh and mine.get ","user":{"login":"manjiki","id":2963436,"avatar_url":"https://avatars.githubusercontent.com/u/2963436?v=3","gravatar_id":"","url":"https://api.github.com/users/manjiki","html_url":"https://github.com/manjiki","followers_url":"https://api.github.com/users/manjiki/followers","following_url":"https://api.github.com/users/manjiki/following{/other_user}","gists_url":"https://api.github.com/users/manjiki/gists{/gist_id}","starred_url":"https://api.github.com/users/manjiki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manjiki/subscriptions","organizations_url":"https://api.github.com/users/manjiki/orgs","repos_url":"https://api.github.com/users/manjiki/repos","events_url":"https://api.github.com/users/manjiki/events{/privacy}","received_events_url":"https://api.github.com/users/manjiki/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-05T14:34:11Z","updated_at":"2016-10-05T14:34:11Z","closed_at":null,"body":"### Description of Issue/Question\r\nUnder some circumstances highstate fails when using salt-ssh and `salt['mine.get']` with errors like:\r\n```\r\nJinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'grains.get'\r\n```\r\nAlthough I am able to successfully run each state individually, I get the above error when running highstate. The problem doesn't occure if we:\r\n* remove the block/state where  `salt['mine.get']` is called\r\n* change the order of states in top.sls\r\n\r\n### Setup\r\n\r\n**Roster file:**\r\n```\r\nmurray2:\r\n  host: 10.10.10.56\r\n  user: dan\r\n  sudo: True\r\n  priv: ~/.ssh/dan.pem\r\n  thin_dir: /opt/salt-thin\r\n  mine_functions:\r\n    network.interfaces: []\r\n    grains.item:\r\n      - roles\r\n      - fqdn\r\n      - applications\r\n      - ip_interfaces\r\n  grains:\r\n    roles:\r\n      - backend\r\n    applications:\r\n      - chuck\r\n````\r\n**states/test_hosts/init.sls:**\r\n```\r\n/etc/hostname:\r\n  file.managed:\r\n    - contents: {{ salt['grains.get']('id') }}\r\n\r\n{%- for host, data in salt['mine.get']('*', 'grains.item').items() %}\r\nhostsfile_{{host}}:\r\n  host.present:\r\n    - names:\r\n      - {{host}}\r\n    - ip: {{data.ip_interfaces.eth0[0]}}\r\n{% endfor%}\r\n```\r\n**states/test_apps/init.sls**\r\n```\r\n{%- for app in salt['grains.get']('applications',[]) %}\r\n{%- set app_data = salt['pillar.get']('applications:%s' % app) %}\r\n{%- from 'test_apps/macros.j2' import this_macro  %}\r\n/tmp/{{app}}:\r\n  file.managed:\r\n    - contents: {{ salt['disk.blkid']('')}}\r\n\r\n{{this_macro(app)}}\r\n{% endfor %}\r\n```\r\n**states/top.sls:**\r\n```\r\nbase:\r\n  '*':\r\n    - test_hosts\r\n    - test_apps\r\n```\r\n\r\n### Steps to Reproduce Issue\r\n```\r\n$ salt-ssh 'murray2' state.highstate\r\n\r\n[ERROR   ] Rendering exception occurred: Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'grains.get'\r\n[CRITICAL] Rendering SLS 'base:test_apps' failed: Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'grains.get'\r\nmurray2:\r\n    - Rendering SLS 'base:test_apps' failed: Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'grains.get'\r\n```\r\nThe last lines of the master.log are:\r\n```\r\n2016-10-05 17:19:03,239 [salt.template    ][PROFILE ][6241] Time (in seconds) to render '/tmp/salt/files/base/test_hosts/init.sls' using 'yaml' renderer: 0.00873517990112\r\n2016-10-05 17:19:03,240 [salt.fileclient  ][DEBUG   ][6241] Could not find file from saltenv 'base', 'salt://test_apps.sls'\r\n2016-10-05 17:19:03,242 [salt.fileclient  ][DEBUG   ][6241] In saltenv 'base', looking at rel_path 'test_apps/init.sls' to resolve 'salt://test_apps/init.sls'\r\n2016-10-05 17:19:03,243 [salt.fileclient  ][DEBUG   ][6241] In saltenv 'base', ** considering ** path '/tmp/salt/files/base/test_apps/init.sls' to resolve 'salt://test_apps/init.sls'\r\n2016-10-05 17:19:03,243 [salt.fileclient  ][DEBUG   ][6241] Fetching file from saltenv 'base', ** attempting ** 'salt://test_apps/init.sls'\r\n2016-10-05 17:19:03,243 [salt.fileclient  ][DEBUG   ][6241] No dest file found\r\n2016-10-05 17:19:03,244 [salt.fileclient  ][INFO    ][6241] Fetching file from saltenv 'base', ** done ** 'test_apps/init.sls'\r\n2016-10-05 17:19:03,244 [salt.template    ][DEBUG   ][6241] compile template: /tmp/salt/files/base/test_apps/init.sls\r\n2016-10-05 17:19:03,245 [salt.utils.jinja ][DEBUG   ][6241] Jinja search path: ['/opt/salt-thin/running_data/var/cache/salt/minion/files/base']\r\n2016-10-05 17:19:03,256 [salt.utils.templates][ERROR   ][6241] Rendering exception occurred: Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'grains.get'\r\n2016-10-05 17:19:03,257 [salt.state       ][CRITICAL][6241] Rendering SLS 'base:test_apps' failed: Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'grains.get'\r\n2016-10-05 17:19:03,362 [salt.utils.lazy  ][DEBUG   ][6232] LazyLoaded nested.output\r\n```\r\n\r\nLastly, highstate runs successfully if I change states order in  the **states/top.sls** file:\r\n```\r\nbase:\r\n  '*':\r\n    - test_apps\r\n    - test_hosts\r\n```\r\n### Versions Report\r\n```\r\nSalt Version:\r\n           Salt: 2016.3.3\r\n \r\nDependency Versions:\r\n           cffi: Not Installed\r\n       cherrypy: Not Installed\r\n       dateutil: 2.5.3\r\n          gitdb: 0.6.4\r\n      gitpython: 1.0.1\r\n          ioflo: Not Installed\r\n         Jinja2: 2.8\r\n        libgit2: Not Installed\r\n        libnacl: Not Installed\r\n       M2Crypto: Not Installed\r\n           Mako: 1.0.3\r\n   msgpack-pure: Not Installed\r\n msgpack-python: 0.4.6\r\n   mysql-python: Not Installed\r\n      pycparser: Not Installed\r\n       pycrypto: 2.6.1\r\n         pygit2: Not Installed\r\n         Python: 2.7.12 (default, Jul  1 2016, 15:12:24)\r\n   python-gnupg: Not Installed\r\n         PyYAML: 3.11\r\n          PyZMQ: 15.2.0\r\n           RAET: Not Installed\r\n          smmap: 0.9.0\r\n        timelib: Not Installed\r\n        Tornado: 4.2.1\r\n            ZMQ: 4.1.4\r\n```"}}
{"actor":{"display_login":"manjiki"}}