i'm currently converting our munin-configuration to salt and would like
to create a state like:
{% for netdev in salt['cmd.run']('ls /sys/class/net/') %}
/etc/munin/plugins/if_{{ netdev }}:
file:
- symlink
- target: /usr/share/munin/plugins/if_
{% endfor %}
'ls /sys/class/net/' should give a list if all network devices
what's the correct syntax to make the loop over netdev work?
cheers
pille
Without testing from a quick glance that looks like valid jinja2. One
"gotcha" of cmd.run is that it doesn't strip the trailling \n so you
need to do that in the template. Try something along the lines of:
{% for netdev in salt['cmd.run']('ls /sys/class/net/').rstrip() %}
--
Jeff Schroeder
Don't drink and derive, alcohol and analysis don't mix.
http://www.digitalprognosis.com
thanks, that totally does what i wanted.
in the meantime i came up with:
{% for netdev in salt['cmd.run']('ls /sys/class/net/').replace('\n', '') %}
that created what i wanted, but also many one-character items. funny.
thanks
pille
On 02/13/2012 05:39 PM, Thomas S Hatch wrote:
> {% for netdev in salt['cmd.run']('ls /sys/class/net/').split() %}thanks, that totally does what i wanted.
in the meantime i came up with:
{% for netdev in salt['cmd.run']('ls /sys/class/net/').replace('\n', '') %}
i am having a similar issue here. in my top file i have states that download and install the package. i later then have a jinja statement that looks at the contents of the installed package. my state files are rendering before everything is in place so im getting an error.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/0ec730fa-d876-4d85-85c6-e5f30d2055aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.