[CRITICAL] Rendering SLS 'base:accumulo' failed: Jinja variable No first item, sequence was empty.local: - Rendering SLS 'base:accumulo' failed: Jinja variable No first item, sequence was empty.
{% if (salt['mine.get']('roles:accumulo_master', 'network.interfaces', 'grain').keys()|first() is none) %}{%- set accumulo_master = salt['mine.get']('roles:accumulo_master', 'network.interfaces', 'grain').keys()|first() %}{%- endif %}{%- set accumulo_master = gc.get('accumulo_master', pc.get('accumulo_master', 'localhost' )) %}
Is this psudo code version correct?
If grain.first() is none:
Set x = grain.first()
I think it might be the second call to first() that's failing since the dict is empty.
If it helps:
Jinja is /almost/ python (at least close enough). In python an empty list or empty dict is falsey ([] == False == {}).
So I think you can just do:
{% if not (salt['mine.get']('roles:accumulo_master', 'network.interfaces', 'grain') %}
To test for an empty dict.
But I'm not sure that's what you wanted.
Nicholas
--
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.
I'm at wits-end with trying to figure out an issue I have with Jinja inside some Pillar configuration.
I've tried a handful of different ways to get this to work, none successful. The 'first()' always seems to fail. The reason I'm trying to handle the 'mine.get' is because I want to be able to support this formula in a 'masterless' environment, where different nodes are all the same machine.
Yeah. Cool.
So you can avoid the initial call to first() by doing this:
If grain:
Set x = grain.keys().first()
Else:
Set x = blah
{% if salt['mine.get']('roles:accumulo_master', 'network.interfaces', 'grain') %}
{%- set accumulo_master = salt['mine.get']('roles:accumulo_master', 'network.interfaces', 'grain').keys()|first() %}
{% else %}
{%- set accumulo_master = gc.get('accumulo_master', pc.get('accumulo_master', 'localhost' )) %}
{%- endif %}{% if salt['mine.get']('roles:accumulo_slave', 'network.interfaces', 'grain') %} {% set accumulo_slaves = salt['mine.get']('roles:accumulo_slave', 'network.interfaces', 'grain').keys() %}{% else %} {%- set accumulo_slaves = gc.get('accumulo_slaves', pc.get('accumulo_slaves', ['localhost'])) %}{% endif %}
[CRITICAL] Rendering SLS 'base:accumulo' failed: Jinja variable No first item, sequence was empty.