Saltstack grains error in template file

Using {{ grains[‘host’] }} in a managed file returns the following error:

 Function: file.managed
      Result: False
     Comment: Unable to manage file: Jinja variable dict object has no element Undefined; line 54

              name = {{ grains['host'] }}    <======================

Sls:

/usr/file.conf:
  file.managed:
    - source: salt://file.jinja
    - template: jinja
    - user: root
    - group: root
    - mode: 644

I have grains working fine elsewhere. Any thoughts?

Answer

Clearing the mine data has fixed this problem:

salt '*' mine.flush

Attribution
Source : Link , Question Author : Joseph Gardner , Answer Author : Nixphoe

Leave a Comment