0

I can't figure out how to remove the last empty line from the output generated by a for and an if Jinja2 statments on SaltStack. I couldn't find a post pointing out the solution neither, as the solutions on internet that I could find don't involve for and if nested statements.

Any help is welcome, thanks.

This is what I tried so far:

{% for user in list_users -%}
  {% if user.enabled == True -%}
    {{ user.name }}:{{ user.passwd }}
  {%- endif %}
{% endfor %}
user1:encrypted_pass
user2:encrypted_pass
user3:encrypted_pass

I also tried adding - at the beginning of the {endfor}:

{% for user in list_users -%}
  {% if user.enabled == True -%}
    {{ user.name }}:{{ user.passwd }}
  {%- endif %}
{%- endfor %}
user1:encrypted_passuser2:encrypted_passuser3:encrypted_pass

Edit: this is the output that I am trying to achieve:

user1:encrypted_pass
user2:encrypted_pass
user3:encrypted_pass

PS: I had a look to the Jinja's whitespace control without success.

jmox
  • 21
  • 5

0 Answers0