Unable to manage file: Jinja variable 'accumulator' is undefined

625 views
Skip to first unread message

Sven Ehret

unread,
Mar 26, 2014, 6:17:04 AM3/26/14
to salt-...@googlegroups.com
Hello List,

I am trying to get a hang with file.accumulated, but keep getting this error: “Unable to manage file: Jinja variable 'accumulator' is undefined”.

The execution log, however, clearly states that the accumulator had been “charged”:
----------
          ID: nrpe-backupchecks___checkbe_combm202-inc
    Function: file.accumulated
        Name: bakcmd
      Result: True
     Comment: Accumulator bakcmd for file C:/program files/NSclient++/nsclient.d/nrpe-backupchecks.ini was charged by text
     Changes:  
----------
          ID: nrpe-backupchecks___checkbe_comts02-inc
    Function: file.accumulated
        Name: bakcmd
      Result: True
     Comment: Accumulator bakcmd for file C:/program files/NSclient++/nsclient.d/nrpe-backupchecks.ini was charged by text
     Changes:  
----------
          ID: nrpe-backupchecks___checkbe_comts02-full
    Function: file.accumulated
        Name: bakcmd
      Result: True
     Comment: Accumulator bakcmd for file C:/program files/NSclient++/nsclient.d/nrpe-backupchecks.ini was charged by text
     Changes:  
----------
          ID: nrpe-backupchecks.ini
    Function: file.managed
        Name: c:/program files/nsclient++/nsclient.d/nrpe-backupchecks.ini
      Result: False
     Comment: Unable to manage file: Jinja variable 'accumulator' is undefined; line 11
             
              ---
              [...]
              #
             
             
             
              [/settings/external scripts/scripts]
              {% for line in accumulator['bakcmd'] %}    <======================
              {{ line }}
              {% endfor %}
              ---
     Changes:



What might I be doing wrong?

Thanks for reading! Best, Sven.

Sven Ehret

unread,
Mar 26, 2014, 6:22:07 AM3/26/14
to salt-...@googlegroups.com
init.sls looks like this:

nrpe-backupchecks.ini:
  file:
    - managed
    - source: salt://win_nsclient/files/nrpe-backupchecks.ini
    - name: 'c:/program files/nsclient++/nsclient.d/nrpe-backupchecks.ini'
    - template: jinja
    - require:
      - file: nsclient.d

{% for backupcheck, args in pillar['nsclient-backups'].iteritems() %}
nrpe-backupchecks___{{ backupcheck }}:
  file:
    - accumulated
    - name: bakcmd
    - filename: 'C:/program files/NSclient++/nsclient.d/nrpe-backupchecks.ini'
    - text:
        {{ backupcheck}}=scripts\be-result-parser.exe -d "{{ args['logdir'] }}" -w{{ args['warning'] }} -c{{ args['critical'] }} -mt{{ args['mondaytolerance'] }} -r "{{ args['searchfilter'] }}"
    - require_in:
      - file: nrpe-backupchecks.ini
    - watch_in:
      - service: nscp
{% endfor %}

and the template file is like this:

[/settings/external scripts/scripts]
{% for line in accumulator['bakcmd'] %}
{{ line }}
{% endfor %}

Colton Myers

unread,
Mar 27, 2014, 6:38:23 PM3/27/14
to salt-...@googlegroups.com
At first glance this appears correct to me, though I've never actually used file.accumulated.  If no one else replies in the next little while, feel free to open up an issue on Github so we can investigate further.

--
Colton Myers


--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sven Ehret

unread,
Mar 28, 2014, 3:43:16 AM3/28/14
to salt-...@googlegroups.com


I guess I am stressing it too hard by calling from within a loop.

Best, Sven.

Michel Samia

unread,
Feb 24, 2015, 10:37:39 AM2/24/15
to salt-...@googlegroups.com
Check that pillar['nsclient-backups'].iteritems() isn't empty. I had this message when I iterated over an empty list. We should consider creating an issue for this, because the error message is a little bit cryptic ;) It should probably say something like "No data were accumulated" or just insert nothing.

Dne pátek 28. března 2014 8:43:16 UTC+1 Sven Ehret napsal(a):
Reply all
Reply to author
Forward
0 new messages