Grains matching / search - sub elements and arrays

39 views
Skip to first unread message

Mariusz Stankiewicz

unread,
Sep 1, 2015, 11:14:18 PM9/1/15
to salt-...@googlegroups.com
Hi,

I have been wondering how to show grains in from a more complex array, or sub grains.  For example I have:

# salt winweb03 grains.item locale_info
winweb03:
    ----------
    locale_info:
        ----------
        defaultencoding:
            cp1252
        defaultlanguage:
            en_US

And I want to show defaultencoding, I have tried doing
# salt winweb03 grains.item locale_info.defaultencoding
or
# salt winweb03 grains.item locale_info:defaultencoding

But I cannot seem to figure out what it should be.


---

Also I was wondering how I could print the first result of a grains array, for example:

# salt winweb03 grains.item 'ipv4'
winweb03:
    ----------
    ipv4:
        - 10.90.1.246
        - 10.90.1.247

How would I print just the first IP in the above grains.item list?



Thanks for your help in advance.

Themalkolm

unread,
Sep 2, 2015, 3:28:15 AM9/2/15
to Salt-users
Try 'grains.get foo:bar' for fetching nested grains.

Mariusz Stankiewicz

unread,
Sep 2, 2015, 3:43:46 AM9/2/15
to salt-...@googlegroups.com
That worked, lifesaver!

On 2 September 2015 at 17:28, Themalkolm <the.m...@gmail.com> wrote:
Try 'grains.get foo:bar' for fetching nested grains.

--
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/d/optout.



--
Mariusz Stankiewicz
0400 008 779
Reply all
Reply to author
Forward
0 new messages