Set var in sls state from module function output

37 views
Skip to first unread message

Maayan Apelboim

unread,
Aug 10, 2017, 9:57:38 AM8/10/17
to Salt-users
Hi all,

I'm trying to run a module function from SLS state and put the output into a variable, but getting the following error: "Jinja variable 'function object' has no attribute 'items' ". 
The output should be dictionary, and eventually I want to only get the key.
What am I missing?


My code example:
{% set sites = salt['win_iis.list_sites'].items() %}


When running the module from salt master I'm getting the following output and would like to use only the site name.
salt server_name state.show_sls iis

Server_name:
    ----------
    Default Web Site:
        ----------
        apppool:
            DefaultAppPool
        bindings:
            ----------
            <ip>:443::
                ----------
                certificatehash:
                certificatestorename:
                hostheader:
                ipaddress:
                    <ip>
                port:
                    443
                protocol:
                    https
                sslflags:
                    0
            <ip>:80::
                ----------
                certificatehash:
                certificatestorename:
                hostheader:
                ipaddress:
                    <ip>
                port:
                    80
                protocol:
                    http
                sslflags:
                    0
        id:
            1
        sourcepath:
            %SystemDrive%\inetpub\wwwroot
        state:
            Started


Thanks

Dafydd Jones (techneg.it)

unread,
Aug 11, 2017, 10:54:51 AM8/11/17
to salt-...@googlegroups.com
Hi,

you are missing something very important, the parentheses to call the function.

{% set sites = salt['win_iis.list_sites']().items() %}

Regards,
Dafydd

--
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/a335ac7e-6ce4-40f9-87a3-3c66a857f8d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages