Hiera targetted value lookup

24 views
Skip to first unread message

tomash

unread,
Jul 24, 2012, 11:08:41 AM7/24/12
to puppet...@googlegroups.com
Hi,

I'm trying to get to grips with hiera and yaml as the backend.

given a yaml file like this:

---
user:
  dave:
    home: "/home/dave"
    shell: "/bin/bash"
  steve:   
    home: "/home/steve"
    shell: "/bin/zsh"

How would I do a hiera lookup for steve's shell?
on the cli, I cannot do "hiera steve.shell" as I might expect.

Obviously I could flatten my yaml and have something like this:
---
dave_home: "/home/dave"
dave_shell: "/bin/bash"
steve_home: "/home/steve"
steve_shell: "/bin/zsh"

But that kind of defeats the point of structured data sets in yaml

Thanks for any help

Tom

Aaron Grewell

unread,
Jul 24, 2012, 1:43:10 PM7/24/12
to puppet...@googlegroups.com
On Tue, Jul 24, 2012 at 8:08 AM, tomash <tom.a...@gmail.com> wrote:
> Hi,
>
> I'm trying to get to grips with hiera and yaml as the backend.
>
> given a yaml file like this:
>
> ---
> user:
> dave:
> home: "/home/dave"
> shell: "/bin/bash"
> steve:
> home: "/home/steve"
> shell: "/bin/zsh"
>
> How would I do a hiera lookup for steve's shell?
> on the cli, I cannot do "hiera steve.shell" as I might expect.

Try something like this:
$user = hiera('user')
$shell = $user['dave']['shell']
Reply all
Reply to author
Forward
0 new messages