Example of how to use require with hiera?

797 views
Skip to first unread message

Daniel Johnson

unread,
Sep 18, 2014, 9:20:08 PM9/18/14
to puppet...@googlegroups.com
Things like

require: File['somefile']

or

require:
File: somefile

both crash, and burn.

Not having a require also causes failure as it tries to do things it
can't without the prerequisite.

After hours of searching I couldn't find any examples to work from.

--
teknotus (Take Notice)

Rich Burroughs

unread,
Sep 19, 2014, 2:43:10 AM9/19/14
to puppet...@googlegroups.com
I'm not clear what the context is here. Those snippets are what's in your YAML file? Maybe you could post the relevant code from your manifest too?


Rich


--
teknotus (Take Notice)

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CA%2BnDE0gpiOywMoEth4OJSG-aYOOB%2BZ17LOy1_YhQ6u8L5NiAcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Antoine Cotten

unread,
Sep 19, 2014, 7:45:43 AM9/19/14
to puppet...@googlegroups.com
Hi teknotus,

I don't think that would work since you can not declare a Puppet resource in Hiera, you are limited to core types.
In your case, Puppet would interpret "File['somefile']" as a string, and "File: somefile" as a hash, but will never translate that to a resource.

Cheers,

Toni

jcbollinger

unread,
Sep 19, 2014, 11:55:58 AM9/19/14
to puppet...@googlegroups.com
That indeed used to be the case.  I have lately heard reports that the string form actually works, however, though I suspect it's core Puppet rather than Hiera that changed to enable it.


John

Nan Liu

unread,
Sep 19, 2014, 12:33:07 PM9/19/14
to puppet...@googlegroups.com
On Thu, Sep 18, 2014 at 6:19 PM, Daniel Johnson <tekn...@gmail.com> wrote:
If you are building a resource hash for create_resources, it's just quoted string:

---
notify:
  example1:
    message: "first"
  example2:
    message: "second"
    require: "Notify[example1]"

create_resources(notify, hiera('notify'))

HTH,

Nan

Antoine Cotten

unread,
Sep 22, 2014, 9:28:47 AM9/22/14
to puppet...@googlegroups.com
Does this actually work Nan??
Can somebody point me to any page where this is documented?

Toni

Daniel Johnson

unread,
Sep 22, 2014, 12:21:53 PM9/22/14
to puppet...@googlegroups.com
> Does this actually work Nan??

It does work. At least in the latest version of puppet.

> Can somebody point me to any page where this is documented?

If I could find documentation for it I wouldn't have asked here.

--
teknotus (Take Notice)
Reply all
Reply to author
Forward
0 new messages