Using modules in sls files. ie network.ip_addrs

123 views
Skip to first unread message

David Ward

unread,
Jun 7, 2013, 12:24:36 AM6/7/13
to salt-...@googlegroups.com
Hi all,

I am trying to set a var to the systems local IP address so I can use it in a template. I am using this:

IP: {{ salt['network.ip_addrs']('eth0') }}


The issue is in the file I have:

  ['10.10.10.11']

All I want is:

  10.10.10.11

Is there a better way? Am I missing something?

Valentin Bud

unread,
Jun 7, 2013, 1:14:00 AM6/7/13
to salt-...@googlegroups.com
Hi David,

Maybe the following blog post [1] would help you.


Cheers,



--
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/groups/opt_out.
 
 



--
w: http://databus.ro/blog

David Ward

unread,
Jun 7, 2013, 2:11:59 AM6/7/13
to salt-...@googlegroups.com
Ahh of course, it is just python and it is returning a list and I am using the whole list, hence the [''] syntax.

So I have changed this:

  IP: {{ salt['network.ip_addrs']('eth0') }}

to:

  IP: {{ salt['network.ip_addrs']('eth0')[0] }}

And rerun my little test file:

localhost:
----------
    State: - file
    Name:      /root/test
    Function:  managed
        Result:    True
        Comment:   File /root/test updated
        Changes:   diff: --- 
+++ 
@@ -1,1 +1,1 @@
-This is the IP ['10.150.0.100']
+This is the IP: 10.150.0.100



Thanks to putting me on the right track Valentin
Reply all
Reply to author
Forward
0 new messages