Conditional variable assignment in Jinja

9,460 views
Skip to first unread message

Corey Quinn

unread,
Mar 2, 2013, 1:06:33 AM3/2/13
to salt-...@googlegroups.com
I put this at the top of my state file, and the renderer melted down.

This probably means that I'm doing something wrong:

{% if grains['os'] == 'MacOS'%}
{% set user='{{ salt['file.stats']('/usr/local/bin/brew')['user'] }}' %}
{% else %}
{% set user = 'rails' %}
{% endif %}

Anyone done something similar?

-- Corey

Jack Kuan

unread,
Mar 2, 2013, 2:06:38 AM3/2/13
to salt-...@googlegroups.com
{% if grains['os'] == 'MacOSx'%}
{% set user = salt['file.stats']('/usr/local/bin/brew')['user'] %}
{% else %}
{% set user = 'rails' %}
{% endif %}

-- 
Jack Kuan
Sent with Sparrow

--
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.


This email and any files transmitted with it are confidential and intended solely for the recipient(s). If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of theScore, Inc. or any of its affiliates. Warning: Although theScore, Inc. has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.

Corey Quinn

unread,
Mar 2, 2013, 2:27:15 AM3/2/13
to salt-...@googlegroups.com
That sorted it-- thanks!

-- Corey
Reply all
Reply to author
Forward
0 new messages